vue-cli搭建項目

1、須要先安裝vue與webpackcss

2、全局安裝vue-clihtml

npm install vue-cli -g

3、打開一個目錄,在這個目錄要建立咱們的項目,而後我使用git bash(用cmd也能夠,可是環境變量要設置對)vue

vue init webpack test

這裏test指的是項目名,該命令執行後會建立一個名爲test的目錄,也就是咱們所搭建的項目。node

接下來會要求你進行一些選項設置,其實就是初始化項目:webpack

? Project name (test)        // 項目名稱
? Project name test
? Project description (A Vue.js project)        // 項目描述
? Project description A Vue.js project
? Author (villelee)        // 做者
? Author villelee
? Vue build (Use arrow keys)        // 開始選項設置
? Vue build standalone
? Install vue-router? (Y/n) Y        // 安裝路由
? Install vue-router? Yes
? Use ESLint to lint your code? (Y/n) Y        // 是否使用ESlint統一代碼風格
? Use ESLint to lint your code? Yes
? Pick an ESLint preset (Use arrow keys)
> Standard (https://github.com/standard/standard)
? Pick an ESLint preset Airbnb
? Set up unit tests (Y/n) n        // 是否安裝單元測試
? Set up unit tests No
? Setup e2e tests with Nightwatch? (Y/n) n        // 是否安裝e2e測試
? Setup e2e tests with Nightwatch? No
? Should we run `npm install` for you after the project has been created? (recom
? Should we run `npm install` for you after the project has been created? (recom
mended) npm
   vue-cli · Generated "test".

最後出現以下代碼git

To get started:

  cd test
  npm run dev

說明已經初始化成功,vue-cli已經將必要的依賴包都下好了,切換到該項目就能夠正常跑起來了。github

$ npm run dev

> test@1.0.0 dev D:\ptest\test
> webpack-dev-server --inline --progress --config build/webpack.dev.conf.js

 95% emitting DONE  Compiled successfully in 5547ms11:59:13

 I  Your application is running here: http://localhost:8080

圖片描述

4、這是生成的項目目錄結構
圖片描述web

5、最後是2018-07-04使用vue-cli搭建完成後的依賴包版本(package.json):vue-router

{
  "name": "test",
  "version": "1.0.0",
  "description": "A Vue.js project",
  "author": "villelee",
  "private": true,
  "scripts": {
    "dev": "webpack-dev-server --inline --progress --config build/webpack.dev.conf.js",
    "start": "npm run dev",
    "lint": "eslint --ext .js,.vue src",
    "build": "node build/build.js"
  },
  "dependencies": {
    "vue": "^2.5.2",
    "vue-router": "^3.0.1"
  },
  "devDependencies": {
    "autoprefixer": "^7.1.2",
    "babel-core": "^6.22.1",
    "babel-eslint": "^8.2.1",
    "babel-helper-vue-jsx-merge-props": "^2.0.3",
    "babel-loader": "^7.1.1",
    "babel-plugin-syntax-jsx": "^6.18.0",
    "babel-plugin-transform-runtime": "^6.22.0",
    "babel-plugin-transform-vue-jsx": "^3.5.0",
    "babel-preset-env": "^1.3.2",
    "babel-preset-stage-2": "^6.22.0",
    "chalk": "^2.0.1",
    "copy-webpack-plugin": "^4.0.1",
    "css-loader": "^0.28.0",
    "eslint": "^4.15.0",
    "eslint-config-airbnb-base": "^11.3.0",
    "eslint-friendly-formatter": "^3.0.0",
    "eslint-import-resolver-webpack": "^0.8.3",
    "eslint-loader": "^1.7.1",
    "eslint-plugin-import": "^2.7.0",
    "eslint-plugin-vue": "^4.0.0",
    "extract-text-webpack-plugin": "^3.0.0",
    "file-loader": "^1.1.4",
    "friendly-errors-webpack-plugin": "^1.6.1",
    "html-webpack-plugin": "^2.30.1",
    "node-notifier": "^5.1.2",
    "optimize-css-assets-webpack-plugin": "^3.2.0",
    "ora": "^1.2.0",
    "portfinder": "^1.0.13",
    "postcss-import": "^11.0.0",
    "postcss-loader": "^2.0.8",
    "postcss-url": "^7.2.1",
    "rimraf": "^2.6.0",
    "semver": "^5.3.0",
    "shelljs": "^0.7.6",
    "uglifyjs-webpack-plugin": "^1.1.1",
    "url-loader": "^0.5.8",
    "vue-loader": "^13.3.0",
    "vue-style-loader": "^3.0.1",
    "vue-template-compiler": "^2.5.2",
    "webpack": "^3.6.0",
    "webpack-bundle-analyzer": "^2.9.0",
    "webpack-dev-server": "^2.9.1",
    "webpack-merge": "^4.1.0"
  },
  "engines": {
    "node": ">= 6.0.0",
    "npm": ">= 3.0.0"
  },
  "browserslist": [
    "> 1%",
    "last 2 versions",
    "not ie <= 8"
  ]
}

能夠看到,即便是使用了vue-cli,像vuex等一些當前比較好用的工具也仍是沒有的。用vue-cli比較大的優點就是能很是傻瓜式地一鍵創建項目的架構,接下來本身要作的就是細化了。vuex

相關文章
相關標籤/搜索