Skip to content

Commit 85c02a9

Browse files
authored
Merge branch 'dev' into upgrade-webpack
2 parents 276ea14 + f9a9880 commit 85c02a9

File tree

122 files changed

+4473
-3296
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

122 files changed

+4473
-3296
lines changed

.eslintrc.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@ module.exports = {
1515
"indent": ["error", 2, {
1616
"MemberExpression": "off"
1717
}],
18+
"no-shadow": ["error"],
1819
"node/no-extraneous-require": ["error", {
1920
"allowModules": [
2021
"@vue/cli-service",

CHANGELOG.md

Lines changed: 267 additions & 0 deletions
Large diffs are not rendered by default.

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
# vue-cli [![Build Status](https://circleci.com/gh/vuejs/vue-cli/tree/dev.svg?style=shield)](https://circleci.com/gh/vuejs/vue-cli/tree/dev) [![Windows Build status](https://ci.appveyor.com/api/projects/status/rkpafdpdwie9lqx0/branch/dev?svg=true)](https://ci.appveyor.com/project/yyx990803/vue-cli/branch/dev) [![lerna](https://img.shields.io/badge/maintained%20with-lerna-cc00ff.svg)](https://lernajs.io/)
1+
# vue-cli [![Build Status](https://circleci.com/gh/vuejs/vue-cli/tree/dev.svg?style=shield)](https://circleci.com/gh/vuejs/vue-cli/tree/dev) [![Windows Build status](https://ci.appveyor.com/api/projects/status/rkpafdpdwie9lqx0/branch/dev?svg=true)](https://ci.appveyor.com/project/yyx990803/vue-cli/branch/dev) [![lerna](https://img.shields.io/badge/maintained%20with-lerna-cc00ff.svg)](https://lerna.js.org/)
22

33

44
> Vue CLI is the Standard Tooling for Vue.js Development.

appveyor.yml

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,6 @@ environment:
33

44
install:
55
- ps: Install-Product node $env:nodejs_version
6-
- yarn patch-chromedriver
76
- yarn --network-timeout 600000
87

98
test_script:

docs/config/README.md

Lines changed: 18 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -247,10 +247,20 @@ See [the plugin's README](https://github.com/vuejs/vue-cli/blob/dev/packages/%40
247247

248248
### css.modules
249249

250+
Deprecated since v4, please use [`css.requireModuleExtension`](#css-requireModuleExtension) instead.
251+
252+
In v3 this means the opposite of `css.requireModuleExtension`.
253+
254+
### css.requireModuleExtension
255+
250256
- Type: `boolean`
251-
- Default: `false`
257+
- Default: `true`
252258

253-
By default, only files that ends in `*.module.[ext]` are treated as CSS modules. Setting this to `true` will allow you to drop `.module` in the filenames and treat all `*.(css|scss|sass|less|styl(us)?)` files as CSS modules.
259+
By default, only files that ends in `*.module.[ext]` are treated as CSS modules. Setting this to `false` will allow you to drop `.module` in the filenames and treat all `*.(css|scss|sass|less|styl(us)?)` files as CSS modules.
260+
261+
::: tip
262+
If you have customized CSS Modules configurations in `css.loaderOptions.css`, then the `css.requireModuleExtension` field must be explictly configured to `true` or `false`, otherwise we can't be sure whether you want to apply these options to all CSS files or not.
263+
:::
254264

255265
See also: [Working with CSS > CSS Modules](../guide/css.md#css-modules)
256266

@@ -304,6 +314,8 @@ See [the plugin's README](https://github.com/vuejs/vue-cli/blob/dev/packages/%40
304314
- [less-loader](https://github.com/webpack-contrib/less-loader)
305315
- [stylus-loader](https://github.com/shama/stylus-loader)
306316

317+
It's also possible to target `scss` syntax separately from `sass`, with the `scss` option.
318+
307319
See also: [Passing Options to Pre-Processor Loaders](../guide/css.md#passing-options-to-pre-processor-loaders)
308320

309321
::: tip
@@ -338,6 +350,10 @@ See [the plugin's README](https://github.com/vuejs/vue-cli/blob/dev/packages/%40
338350

339351
This will tell the dev server to proxy any unknown requests (requests that did not match a static file) to `http://localhost:4000`.
340352

353+
::: warning
354+
When `devServer.proxy` is set to a string, only XHR requests will be proxied. If you want to test an API URL, don't open it in the browser, use an API tool like Postman instead.
355+
:::
356+
341357
If you want to have more control over the proxy behavior, you can also use an object with `path: options` pairs. Consult [http-proxy-middleware](https://github.com/chimurai/http-proxy-middleware#proxycontext-config) for full options:
342358

343359
``` js

docs/core-plugins/e2e-nightwatch.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@
2020

2121
> Note: this plugin currently uses Nightwatch v0.9.x. We are waiting for Nightwatch 1.0 to stabilize before upgrading.
2222
23-
Additionally, [all Nightwatch CLI options are also supported](https://github.com/nightwatchjs/nightwatch/blob/master/lib/runner/cli/cli.js).
23+
Additionally, [all Nightwatch CLI options are also supported](https://nightwatchjs.org/guide#command-line-options).
2424

2525
## Configuration
2626

docs/dev-guide/generator-api.md

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,8 @@ The version string for the **project local** `@vue/cli-service` version that is
3838

3939
Nothing happens if the provided version is satisfied. Otherwise, an error will be thrown.
4040

41+
Note: It's recommended to use [the `peerDependencies` field in `package.json`](https://docs.npmjs.com/files/package.json#peerdependencies) under most circumstances.
42+
4143

4244
## resolve
4345

@@ -54,12 +56,13 @@ Resolve a path for the current project
5456

5557
- **Arguments**
5658
- `{string} id` - plugin id, can omit the (@vue/|vue-|@scope/vue)-cli-plugin- prefix
59+
- `{string} version` - semver version range, optional
5760

5861
- **Returns**
5962
- `{boolean}`
6063

6164
- **Usage**:
62-
Check if the project has a plugin with given id
65+
Check if the project has a plugin with given id. If version range is given, then the plugin version should satisfy it
6366

6467
## addConfigTransform
6568

@@ -177,4 +180,3 @@ Get the entry file taking into account typescript.
177180

178181
- **Usage**:
179182
Checks if the plugin is being invoked.
180-

docs/dev-guide/plugin-api.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,8 @@ The version string for the `@vue/cli-service` version that is loading the plugin
1919

2020
Nothing happens if the provided version is satisfied. Otherwise, an error will be thrown.
2121

22+
Note: It's recommended to use [the `peerDependencies` field in `package.json`](https://docs.npmjs.com/files/package.json#peerdependencies) under most circumstances.
23+
2224
## getCwd
2325

2426
- **Usage**:

docs/dev-guide/plugin-dev.md

Lines changed: 30 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -241,51 +241,57 @@ Let's consider the case where we have created a `router.js` file via [templating
241241
api.injectImports(api.entryFile, `import router from './router'`)
242242
```
243243

244-
Now, when we have a router imported, we can inject this router to the Vue instance in the main file. We will use `onCreateComplete` hook which is to be called when the files have been written to disk.
244+
Now, when we have a router imported, we can inject this router to the Vue instance in the main file. We will use `afterInvoke` hook which is to be called when the files have been written to disk.
245245

246246
First, we need to read main file content with Node `fs` module (which provides an API for interacting with the file system) and split this content on lines:
247247

248248
```js
249249
// generator/index.js
250250

251-
api.onCreateComplete(() => {
252-
const fs = require('fs')
253-
const contentMain = fs.readFileSync(api.entryFile, { encoding: 'utf-8' })
254-
const lines = contentMain.split(/\r?\n/g)
255-
})
251+
module.exports.hooks = (api) => {
252+
api.afterInvoke(() => {
253+
const fs = require('fs')
254+
const contentMain = fs.readFileSync(api.entryFile, { encoding: 'utf-8' })
255+
const lines = contentMain.split(/\r?\n/g)
256+
})
257+
}
256258
```
257259

258260
Then we should to find the string containing `render` word (it's usually a part of Vue instance) and add our `router` as a next string:
259261

260-
```js{8-9}
262+
```js{9-10}
261263
// generator/index.js
262264
263-
api.onCreateComplete(() => {
264-
const fs = require('fs')
265-
const contentMain = fs.readFileSync(api.entryFile, { encoding: 'utf-8' })
266-
const lines = contentMain.split(/\r?\n/g)
265+
module.exports.hooks = (api) => {
266+
api.afterInvoke(() => {
267+
const fs = require('fs')
268+
const contentMain = fs.readFileSync(api.entryFile, { encoding: 'utf-8' })
269+
const lines = contentMain.split(/\r?\n/g)
267270
268-
const renderIndex = lines.findIndex(line => line.match(/render/))
269-
lines[renderIndex] += `\n router,`
270-
})
271+
const renderIndex = lines.findIndex(line => line.match(/render/))
272+
lines[renderIndex] += `\n router,`
273+
})
274+
}
271275
```
272276

273277
Finally, you need to write the content back to the main file:
274278

275-
```js{2,11}
279+
```js{12-13}
276280
// generator/index.js
277281
278-
api.onCreateComplete(() => {
279-
const { EOL } = require('os')
280-
const fs = require('fs')
281-
const contentMain = fs.readFileSync(api.entryFile, { encoding: 'utf-8' })
282-
const lines = contentMain.split(/\r?\n/g)
282+
module.exports.hooks = (api) => {
283+
api.afterInvoke(() => {
284+
const { EOL } = require('os')
285+
const fs = require('fs')
286+
const contentMain = fs.readFileSync(api.entryFile, { encoding: 'utf-8' })
287+
const lines = contentMain.split(/\r?\n/g)
283288
284-
const renderIndex = lines.findIndex(line => line.match(/render/))
285-
lines[renderIndex] += `${EOL} router,`
289+
const renderIndex = lines.findIndex(line => line.match(/render/))
290+
lines[renderIndex] += `${EOL} router,`
286291
287-
fs.writeFileSync(api.entryFile, lines.join(EOL), { encoding: 'utf-8' })
288-
})
292+
fs.writeFileSync(api.entryFile, lines.join(EOL), { encoding: 'utf-8' })
293+
})
294+
}
289295
```
290296

291297
## Service Plugin

docs/guide/css.md

Lines changed: 19 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -89,13 +89,13 @@ import styles from './foo.module.css'
8989
import sassStyles from './foo.module.scss'
9090
```
9191

92-
If you want to drop the `.module` in the filenames, set `css.modules` to `true` in `vue.config.js`:
92+
If you want to drop the `.module` in the filenames, set `css.requireModuleExtension` to `false` in `vue.config.js`:
9393

9494
``` js
9595
// vue.config.js
9696
module.exports = {
9797
css: {
98-
modules: true
98+
requireModuleExtension: false
9999
}
100100
}
101101
```
@@ -108,8 +108,13 @@ module.exports = {
108108
css: {
109109
loaderOptions: {
110110
css: {
111-
localIdentName: '[name]-[hash]',
112-
camelCase: 'only'
111+
// Note: the following config format is different between Vue CLI v4 and v3
112+
// For Vue CLI v3 users, please refer to css-loader v1 documentations
113+
// https://github.com/webpack-contrib/css-loader/tree/v1.0.1
114+
modules: {
115+
localIdentName: '[name]-[hash]',
116+
localsConvention: 'camelCaseOnly'
117+
}
113118
}
114119
}
115120
}
@@ -126,9 +131,17 @@ module.exports = {
126131
css: {
127132
loaderOptions: {
128133
// pass options to sass-loader
134+
// @/ is an alias to src/
135+
// so this assumes you have a file named `src/variables.sass`
129136
sass: {
130-
// @/ is an alias to src/
131-
// so this assumes you have a file named `src/variables.scss`
137+
data: `@import "~@/variables.sass"`
138+
},
139+
// by default the `sass` option will apply to both syntaxes
140+
// because `scss` syntax is also processed by sass-loader underlyingly
141+
// but when configuring the `data` option
142+
// `scss` syntax requires an semicolon at the end of a statement, while `sass` syntax requires none
143+
// in that case, we can target the `scss` syntax separately using the `scss` option
144+
scss: {
132145
data: `@import "~@/variables.scss";`
133146
},
134147
// pass Less.js Options to less-loader

docs/guide/deployment.md

Lines changed: 51 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -265,49 +265,77 @@ Please refer to the [Firebase Documentation](https://firebase.google.com/docs/ho
265265

266266
### Now
267267

268-
1. Install the Now CLI globally:
268+
This example uses the latest Now platform version 2.
269+
270+
1. Install the Now CLI:
269271

270272
```bash
271273
npm install -g now
274+
275+
# Or, if you prefer a local one
276+
npm install now
272277
```
273278

274279
2. Add a `now.json` file to your project root:
275280

276281
```json
277282
{
278283
"name": "my-example-app",
279-
"type": "static",
280-
"static": {
281-
"public": "dist",
282-
"rewrites": [
283-
{
284-
"source": "**",
285-
"destination": "/index.html"
286-
}
287-
]
288-
},
289-
"alias": "vue-example",
290-
"files": [
291-
"dist"
292-
]
284+
"version": 2,
285+
"builds": [
286+
{
287+
"src": "package.json",
288+
"use": "@now/static-build"
289+
}
290+
],
291+
"routes": [
292+
{
293+
"src": "/(js|css|img)/.*",
294+
"headers": { "cache-control": "max-age=31536000, immutable" }
295+
},
296+
{ "handle": "filesystem" },
297+
{ "src": ".*", "dest": "/" }
298+
],
299+
"alias": "example.com"
293300
}
294301
```
295302

296-
You can further customize the static serving behavior by consulting [Now's documentation](https://zeit.co/docs/deployment-types/static).
297-
298-
3. Adding a deployment script in `package.json`:
303+
If you have different/additional folders, modify the route accordingly:
304+
305+
```diff
306+
- {
307+
- "src": "/(js|css|img)/.*",
308+
- "headers": { "cache-control": "max-age=31536000, immutable" }
309+
- }
310+
+ {
311+
+ "src": "/(js|css|img|fonts|media)/.*",
312+
+ "headers": { "cache-control": "max-age=31536000, immutable" }
313+
+ }
314+
```
299315

300-
```json
301-
"deploy": "npm run build && now && now alias"
316+
If your `outputDir` is not the default `dist`, say `build`:
317+
318+
```diff
319+
- {
320+
- "src": "package.json",
321+
- "use": "@now/static-build"
322+
- }
323+
+ {
324+
+ "src": "package.json",
325+
+ "use": "@now/static-build",
326+
+ "config": { "distDir": "build" }
327+
+ }
302328
```
303329

304-
If you want to deploy publicly by default, you can change the deployment script to the following one:
330+
3. Adding a `now-build` script in `package.json`:
305331

306332
```json
307-
"deploy": "npm run build && now --public && now alias"
333+
"now-build": "npm run build"
308334
```
335+
336+
To make a deployment, run `now`.
309337

310-
This will automatically point your site's alias to the latest deployment. Now, just run `npm run deploy` to deploy your app.
338+
If you want your deployment aliased, run `now --target production` instead.
311339

312340
### Stdlib
313341

docs/guide/mode-and-env.md

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -46,6 +46,8 @@ FOO=bar
4646
VUE_APP_SECRET=secret
4747
```
4848

49+
Note that only variables that start with `VUE_APP_` will be statically embedded into the client bundle with `webpack.DefinePlugin`.
50+
4951
For more detailed env parsing rules, please refer to [the documentation of `dotenv`](https://github.com/motdotla/dotenv#rules). We also use [dotenv-expand](https://github.com/motdotla/dotenv-expand) for variable expansion (available in Vue CLI 3.5+).
5052

5153
Loaded variables will become available to all `vue-cli-service` commands, plugins and dependencies.
@@ -55,6 +57,8 @@ Loaded variables will become available to all `vue-cli-service` commands, plugin
5557
An env file for a specific mode (e.g. `.env.production`) will take higher priority than a generic one (e.g. `.env`).
5658

5759
In addition, environment variables that already exist when Vue CLI is executed have the highest priority and will not be overwritten by `.env` files.
60+
61+
`.env` files are loaded at the start of `vue-cli-service`. Restart the service after making changes.
5862
:::
5963

6064
### Example: Staging Mode
@@ -80,7 +84,7 @@ In both cases, the app is built as a production app because of the `NODE_ENV`, b
8084

8185
### Using Env Variables in Client-side Code
8286

83-
Only variables that start with `VUE_APP_` will be statically embedded into the client bundle with `webpack.DefinePlugin`. You can access them in your application code:
87+
You can access env variables in your application code:
8488

8589
``` js
8690
console.log(process.env.VUE_APP_SECRET)

docs/guide/prototyping.md

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -20,9 +20,10 @@ serve a .js or .vue file in development mode with zero config
2020
2121
Options:
2222
23-
-o, --open Open browser
24-
-c, --copy Copy local url to clipboard
25-
-h, --help output usage information
23+
-o, --open Open browser
24+
-c, --copy Copy local url to clipboard
25+
-p, --port <port> Port used by the server (default: 8080 or next available port)
26+
-h, --help Output usage information
2627
```
2728

2829
All you need is an `App.vue` file:

docs/ru/guide/README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ Vue CLI состоит из нескольких составных частей
3030

3131
### CLI
3232

33-
CLI (`@vue/cli`) — это npm-пакет, устанавливаемый глобально и предоставляющий команду `vue` в терминале. Он позволяет быстро создать новый проект командой `vue create`, или мгновенно прототипировать ваши новые идеи через `vue serve`. Также можно управлять проектами в графическом интерфейсе через `vue ui`. Мы рассмотрим, что он может делать в следующих разделах руководства.
33+
CLI (`@vue/cli`) — это npm-пакет, устанавливаемый глобально и предоставляющий команду `vue` в терминале. Он позволяет быстро создать новый проект командой `vue create`, или мгновенно прототипировать ваши новые идеи через `vue serve`. Также можно управлять проектами в графическом интерфейсе через `vue ui`. Мы рассмотрим, что он может делать, в следующих разделах руководства.
3434

3535
### Сервис CLI
3636

0 commit comments

Comments
 (0)