|
1 |
| -# WIP |
| 1 | +## Table of Contents |
| 2 | + |
| 3 | +- [Introduction](#introduction) |
| 4 | +- [CLI](#cli) |
| 5 | +- [CLI Service](#cli-service) |
| 6 | +- [Configuration](#configuration) |
| 7 | + - [webpack](#webpack) |
| 8 | + - [browserslist](#browserslist) |
| 9 | + - [Babel](#babel) |
| 10 | + - [CSS](#css) |
| 11 | + - [ESLint](#eslint) |
| 12 | + - [TypeScript](#typescript) |
| 13 | + - [Unit Testing](#unit-testing) |
| 14 | + - [E2E Testing](#e2e-testing) |
| 15 | +- [Environment Variables and Modes](#environment-variables-and-modes) |
| 16 | +- [Development](#development) |
2 | 17 |
|
3 | 18 | ## Introduction
|
4 | 19 |
|
5 |
| -## The CLI |
| 20 | +Vue CLI is a full system for rapid Vue.js development, providing: |
| 21 | + |
| 22 | +- Interactive project scaffolding via `@vue/cli`. |
| 23 | +- Zero config rapid prototyping via `@vue/cli` + `@vue/cli-service-global`. |
| 24 | +- A runtime dependency (`@vue/cli-service`) that is: |
| 25 | + - Upgradeable; |
| 26 | + - Built on top of webpack, with sensible defaults; |
| 27 | + - Configurable via in-project config file; |
| 28 | + - Extensible via plugins
67E6
td> |
| 29 | +- A rich collection of official plugins integrating the best tools in the frontend ecosystem. |
| 30 | + |
| 31 | +Vue CLI aims to be the standard tooling baseline for the Vue ecosystem. It ensures the various build tools work smoothly together with sensible defaults so you can focus on writing your app instead of spending days wrangling with configurations. At the same time, it still offers the flexibility to tweak the config of each tool without the need for ejecting. |
| 32 | + |
| 33 | +## CLI |
| 34 | + |
| 35 | +The CLI is installed globally and provides the `vue` command in your terminal: |
| 36 | + |
| 37 | +``` sh |
| 38 | +npm install -g @vue/cli |
| 39 | +vue create my-project |
| 40 | +``` |
| 41 | + |
| 42 | +For full details on what the `vue` command can do, see the [full CLI docs](https://github.com/vuejs/vue-cli/blob/dev/packages/%40vue/cli/README.md). |
| 43 | + |
| 44 | +## CLI Service |
| 45 | + |
| 46 | +`@vue/cli-service` is a dependency installed locally into every project created by `@vue/cli`. It contains the core service that loads other plugins, resolves the final webpack config, and provides the `vue-cli-service` binary to your project. The binary exposes commands such as `
A3E2
vue-cli-service serve`, which can be used in npm scripts. If you are familiar with [create-react-app](https://github.com/facebookincubator/create-react-app), `@vue/cli-service` is essentially the equivalent of `react-scripts`, but more flexible. |
6 | 47 |
|
7 | 48 | ## Configuration
|
8 | 49 |
|
9 |
| -### Vue CLI options |
| 50 | +Projects created from `vue create` are ready to go out-of-the-box. The plugins are designed to work with one another so in most cases, all you need to do is pick the features you want during the interactive prompts. |
| 51 | + |
| 52 | +However, we also understand that it's impossible to cater to every possible need, and the need of a project may also change over time. Projects created by Vue CLI allows you to configure almost every aspect of the tooling without ever needing to eject. |
| 53 | + |
| 54 | +### vue.config.js |
| 55 | + |
| 56 | +Many aspects of a Vue CLI project can be configured by placing a `vue.config.js` file at the root of your project. The file may already exist depending on the features you selected when creating the project. |
| 57 | + |
| 58 | +`vue.config.js` should export an object, for example: |
| 59 | + |
| 60 | +``` js |
| 61 | +// vue.config.js |
| 62 | +module.exports = { |
| 63 | + lintOnSave: true |
| 64 | +} |
| 65 | +``` |
| 66 | + |
| 67 | +Check [here](./config.md) for full list of possible options. |
| 68 | + |
| 69 | +### webpack |
10 | 70 |
|
11 |
| -### Modes and Environment Variables |
| 71 | +Probably the most common configuration need is tweaking the internal webpack config. Vue CLI provides flexible ways to achieve that without ejecting. |
12 | 72 |
|
13 |
| -### Webpack |
| 73 | +See [here](./webpack.md) for full details. |
14 | 74 |
|
15 |
| -- #### Basic Configuration |
| 75 | +### browserlist |
16 | 76 |
|
17 |
| -- #### Chaining |
| 77 | +You will notice a `browserlist` field in `package.json` specifying a range of browsers the project is targeting. This value will be used by `babel-preset-env` and `autoprefixer` to automatically determine the JavaScript polyfills and CSS vendor prefixes needed. |
18 | 78 |
|
19 |
| -- #### Using Resolved Config as a File |
| 79 | +See [here](https://github.com/ai/browserslist) for how to specify browser ranges. |
20 | 80 |
|
21 | 81 | ### Babel
|
22 | 82 |
|
23 |
| -- link to: babel preset |
24 |
| -- link to: babel plugin |
| 83 | +Babel can be configured via `.babelrc` or the `babel` field in `package.json`. |
25 | 84 |
|
26 |
| -### CSS |
| 85 | +All Vue CLI apps use `@vue/babel-preset-app` by default, which includes: |
| 86 | + |
| 87 | +- [babel-preset-env](https://github.com/babel/babel/tree/master/packages/babel-preset-env) |
| 88 | +- [dynamic import syntax](https://github.com/tc39/proposal-dynamic-import) |
| 89 | +- [Object rest spread](https://github.com/tc39/proposal-object-rest-spread) |
| 90 | +- [babel-preset-stage-2](https://github.com/babel/babel/tree/master/packages/babel-preset-stage-2) |
| 91 | +- Vue JSX support |
27 | 92 |
|
28 |
| -- #### PostCSS |
| 93 | +See [@vue/babel-preset-app](https://github.com/vuejs/vue-cli/tree/dev/packages/%40vue/babel-preset-app) for preset options. |
| 94 | + |
| 95 | +### CSS |
29 | 96 |
|
30 |
| -- #### CSS Modules |
| 97 | +Vue CLI projects comes with support for [PostCSS](http://postcss.org/), [CSS Modules](https://github.com/css-modules/css-modules) and pre-processors including [Sass](https://sass-lang.com/), [Less](http://lesscss.org/) and [Stylus](http://stylus-lang.com/). |
31 | 98 |
|
32 |
| -- #### Other Pre-Processors |
| 99 | +See [here](./css.md) for more details on CSS related configurations. |
33 | 100 |
|
34 | 101 | ### ESLint
|
35 | 102 |
|
36 |
| -- link to: eslint plugin |
| 103 | +ESLint can be configured via `.eslintrc` or `eslintConfig` field in `package.json`. |
| 104 | + |
| 105 | +See [@vue/cli-plugin-eslint](https://github.com/vuejs/vue-cli/tree/dev/packages/%40vue/cli-plugin-eslint) for more details. |
37 | 106 |
|
38 | 107 | ### TypeScript
|
39 | 108 |
|
40 |
| -- link to: typescript plugin |
| 109 | +TypeScript can be configured via `tsconfig.json`. |
| 110 | + |
| 111 | +See [@vue/cli-plugin-typescript](https://github.com/vuejs/vue-cli/tree/dev/packages/%40vue/cli-plugin-typescript) for more details. |
41 | 112 |
|
42 | 113 | ### Unit Testing
|
43 | 114 |
|
44 | 115 | - #### Jest
|
45 | 116 |
|
| 117 | + See [@vue/cli-plugin-unit-jest](https://github.com/vuejs/vue-cli/tree/dev/packages/%40vue/cli-plugin-unit-jest) for more details. |
| 118 | + |
46 | 119 | - #### Mocha (via `mocha-webpack`)
|
47 | 120 |
|
| 121 | + See [@vue/cli-plugin-unit-mocha](https://github.com/vuejs/vue-cli/tree/dev/packages/%40vue/cli-plugin-unit-mocha) for more details. |
| 122 | + |
48 | 123 | ### E2E Testing
|
49 | 124 |
|
50 | 125 | - #### Cypress
|
51 | 126 |
|
| 127 | + See [@vue/cli-plugin-e2e-cypress](https://github.com/vuejs/vue-cli/tree/dev/packages/%40vue/cli-plugin-e2e-cypress) for more details. |
| 128 | + |
52 | 129 | - #### Nightwatch
|
| 130 | + |
| 131 | + See [@vue/cli-plugin-e2e-nightwatch](https://github.com/vuejs/vue-cli/tree/dev/packages/%40vue/cli-plugin-e2e-nightwatch) for more details. |
| 132 | + |
| 133 | +## Environment Variables and Modes |
| 134 | + |
| 135 | +It is a common need to customize the app's behavior based on the target environment - for example, you may want the app to use different API endpoints or credentials during development / staging / production environments. |
| 136 | + |
| 137 | +Vue CLI has comprehensive support for specifying different environment variables - see the [dedicated section](./env.md) for more details. |
| 138 | + |
| 139 | +## Development |
| 140 | + |
| 141 | +- [Contributing Guide](https://github.com/vuejs/vue-cli/blob/dev/.github/CONTRIBUTING.md) |
| 142 | +- [Plugin Development Guide](https://github.com/vuejs/vue-cli/blob/dev/docs/plugin.md). |
0 commit comments