vue-cli是用來生成 vue項目的命令行工具,它的使用方法是這樣的:css
vue init <template-name> <project-name>
第二個參數 template-name 就是咱們打算使用的模板,目前,模板是經過github上vue-templates這個組織進行發佈。咱們一般使用的vue init webpack my-project, 其中webpack指的就是 基於webpack的vuejs初始化模板。
本文就根據webpack這套模板(https://github.com/vuejs-templates/webpack/tree/master/template)
進行介紹,基於的版本是#658html
首先來到package.json文件裏,package.json是npm的配置文件,裏面設定了腳本以及項目依賴的庫。 npm run dev 這樣的命令就寫在package.json裏。vue
{ "name": "my-self-project",//項目名稱 "version": "1.0.0",//版本 "description": "A Vue.js project",//描述 "author": "shangxiaofei <shangxiaofei3@163.com>",//做者 "private": true,//是否私人項目 "scripts": { "dev": "webpack-dev-server --inline --progress --config build/webpack.dev.conf.js",//// npm run dev 的 dev,使用node執行 build/dev-server.js "start": "npm run dev",// npm run start 跑的是一樣的命令 "build": "node build/build.js"//npm run build 跑的是 node build/build.js // 如下腳本爲單元測試用到的腳本 "unit": "jest --config test/unit/jest.conf.js --coverage", "e2e": "node test/e2e/runner.js", "test": "npm run unit && npm run e2e", "lint": "eslint --ext .js,.vue src test/unit test/e2e/specs", }, // dependencies 設定的是項目裏使用的依賴,devDependencies設定的是開發使用的依賴 "dependencies": { "vue": "^2.5.2",// 項目依賴vue.js "vue-router": "^3.0.1"// 項目依賴vue-router }, "devDependencies": { "autoprefixer": "^7.1.2",//是用於給css3屬性自動加屬性前綴的 // babel相關的都是用於處理es6語法的 "babel-core": "^6.22.1", "babel-eslint": "^8.2.1", "babel-helper-vue-jsx-merge-props": "^2.0.3", "babel-jest": "^21.0.2", "babel-loader": "^7.1.1", "babel-plugin-dynamic-import-node": "^1.2.0", "babel-plugin-syntax-jsx": "^6.18.0", "babel-plugin-transform-es2015-modules-commonjs": "^6.26.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", "babel-register": "^6.22.0", "chalk": "^2.0.1", "chromedriver": "^2.27.2", "copy-webpack-plugin": "^4.0.1", "cross-spawn": "^5.0.1", "css-loader": "^0.28.0", "eslint": "^4.15.0", "eslint-config-standard": "^10.2.1", "eslint-friendly-formatter": "^3.0.0", "eslint-loader": "^1.7.1", "eslint-plugin-import": "^2.7.0", "eslint-plugin-node": "^5.2.0", "eslint-plugin-promise": "^3.4.0", "eslint-plugin-standard": "^3.0.1", "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", "jest": "^22.0.4", "jest-serializer-vue": "^0.3.0", "nightwatch": "^0.9.12", "node-notifier": "^5.1.2", "optimize-css-assets-webpack-plugin": "^3.2.0", "ora": "^1.2.0",// 命令行裏自動運行的信息提示 "postcss-import": "^11.0.0", "postcss-loader": "^2.0.8", "postcss-url": "^7.2.1", "rimraf": "^2.6.0",// 跑shell命令 rm-rf 的工具 "selenium-server": "^3.0.1", "semver": "^5.3.0", "shelljs": "^0.7.6", "uglifyjs-webpack-plugin": "^1.1.1", "url-loader": "^0.5.8",// 配合webpack的加載器 "vue-jest": "^1.0.2", "vue-loader": "^13.3.0",// 配合webpack的加載器 "vue-style-loader": "^3.0.1",// 配合webpack的加載器 "vue-template-compiler": "^2.5.2",// vue-template-compiler,多是配合離線版vue // webpack相關的用於,把圖片,*.vue, *.js, 這些組合成最終的項目,webpack-dev用於跑測試服務器 "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" ] }
做者:fishenal
連接:https://www.imooc.com/article/17770?block_id=tuijian_wz
來源:慕課網
本文原創發佈於慕課網 ,轉載請註明出處,謝謝合做java