Vue-cli为Vue官方项目构建工具,能够帮助开发者快速搭建一个Vue项目。
安装
1
2// 全局安装
npm install -g @vue/cli创建项目
1
2vue create project // 命令行创建
vue ui // 图形化创建创建选项
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34// 设置方式
default (babel, eslint) // 默认设置
Manually select features // 手动设置
// 手动设置选项 (按空格选择,按Enter确定)
Babel // 支持 Babel。
TypeScript // 支持使用 TypeScript 书写源码。
Progressive Web App (PWA) Support // PWA 支持。
Router // 支持 vue-router 。
Vuex // 支持 vuex 。
CSS Pre-processors // 支持 CSS 预处理器。
Linter / Formatter // 支持代码风格检查和格式化。
Unit Testing // 支持单元测试。
E2E Testing // 支持 E2E 测试。
// CSS预处理器设置
Sass/SCSS (with dart-sass)
Sass/SCSS (with node-sass)
Less
Stylus
// ESLint设置
ESLint with error prevention only
ESLint + Airbnb config
ESLint + Standard config
ESLint + Prettier
// 检查设置
Lint on save
Lint and fix on commit
// 文件设置
In dedicated config files // 分开在专用配置文件中
In package.json // 统一在package.json文件中项目运行
1
2cd project // 进入项目根目录
npm run serve // 运行项目项目打包
1
npm run build
单元测试
1
npm run test
