Skip to content

Commit fb97646

Browse files
committed
docs: more content
1 parent 252fa36 commit fb97646

File tree

4 files changed

+62
-15
lines changed

4 files changed

+62
-15
lines changed

docs/config/README.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -98,6 +98,10 @@ module.exports = {
9898
}
9999
```
100100

101+
::: tip
102+
When building in multi-page mode, the webpack config will contain different plugins (there will be multiple instances of `html-webpack-plugin` and `preload-webpack-plugin`). Make sure to run `vue inspect` if you are trying to modify the options for those plugins.
103+
:::
104+
101105
### lintOnSave
102106

103107
- Type: `boolean`

docs/dev-guide/plugin-dev.md

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -282,6 +282,14 @@ Alternatively, the user can skip the prompts and directly initialize the plugin
282282
vue invoke my-plugin --mode awesome
283283
```
284284

285+
## Distributing the Plugin
286+
287+
For a CLI plugin to be usable by other developers, it must be published on npm following the name convention `vue-cli-plugin-<name>`. Following the name convention allows your plugin to be:
288+
289+
- Discoverable by `@vue/cli-service`;
290+
- Discoverable by other developers via searching;
291+
- Installable via `vue add <name>` or `vue invoke <name>`.
292+
285293
## Note on Development of Core Plugins
286294

287295
::: tip Note

docs/guide/html-and-static-assets.md

Lines changed: 28 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,13 +8,20 @@ The file `public/index.html` is a template that will be processed with [html-web
88

99
### Interpolation
1010

11-
Since the index file is used as a template, you can use the [lodash template](https://lodash.com/docs/4.17.10#template) syntax to interpolate values in it. In addition to the [default values exposed by `html-webpack-plugin`](https://github.com/jantimon/html-webpack-plugin#writing-your-own-templates), all [client-side env variables](./mode-and-env.md#using-env-variables-in-client-side-code) are also available directly. For example, to use the `BASE_URL` value:
11+
Since the index file is used as a template, you can use the [lodash template](https://lodash.com/docs/4.17.10#template) syntax to interpolate values in it:
12+
13+
- `<%= VALUE %>` for unescaped interpolation;
14+
- `<%- VALUE %>` for HTML-escaped interpolation;
15+
- `<% expression %>` for JavaScript control flows.
16+
17+
In addition to the [default values exposed by `html-webpack-plugin`](https://github.com/jantimon/html-webpack-plugin#writing-your-own-templates), all [client-side env variables](./mode-and-env.md#using-env-variables-in-client-side-code) are also available directly. For example, to use the `BASE_URL` value:
1218

1319
``` html
1420
<link rel="icon" href="<%= BASE_URL %>favicon.ico">
1521
```
1622

17-
See also: [baseUrl](../config/#baseurl)
23+
See also:
24+
- [baseUrl](../config/#baseurl)
1825

1926
### Preload
2027

@@ -32,6 +39,25 @@ By default, a Vue CLI app will automatically generate prefetch hints for all Jav
3239

3340
The hints are injected using [@vue/preload-webpack-plugin](https://github.com/vuejs/preload-webpack-plugin) and can be modified / deleted via `chainWebpack` as `config.plugin('prefetch')`.
3441

42+
Example:
43+
44+
``` js
45+
// vue.config.js
46+
module.exports = {
47+
chainWebpack: config => {
48+
// remove the prefetch plugin
49+
config.plugins.delete('prefetch')
50+
51+
// or:
52+
// modify its options:
53+
config.plugin('prefetch').tap(options => {
54+
options.fileBlackList.push([/myasyncRoute(.)+?\.js$/])
55+
return options
56+
})
57+
}
58+
}
59+
```
60+
3561
::: tip
3662
Prefetch links will consume bandwidth. If you have a large app with many async chunks and your user are primarily mobile and thus bandwidth-aware, you may want to disable prefetch links.
3763
:::

docs/guide/mode-and-env.md

Lines changed: 22 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,27 @@ You can overwrite the default mode used for a command by passing the `--mode` op
3636
"dev-build": "vue-cli-service build --mode development",
3737
```
3838

39+
## Example: Staging Mode
40+
41+
Assuming we have an app with the following `.env` file:
42+
43+
```
44+
VUE_APP_TITLE=My App
45+
```
46+
47+
And the following `.env.staging` file:
48+
49+
```
50+
NODE_ENV=production
51+
VUE_APP_TITLE=My App (staging)
52+
```
53+
54+
- `vue-cli-service build` builds a production app, loading `.env`, `.env.production` and `.env.production.local` if they are present;
55+
56+
- `vue-cli-service build --mode staging` builds a production app in staging mode, using `.env`, `.env.staging` and `.env.staging.local` if they are present.
57+
58+
In both cases, the app is built as a production app because of the `NODE_ENV`, but in the staging version, `process.env.VUE_APP_TITLE` is overwritten with a different value.
59+
3960
## Using Env Variables in Client-side Code
4061

4162
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:
@@ -51,19 +72,7 @@ In addition to `VUE_APP_*` variables, there are also two special variables that
5172
- `NODE_ENV` - this will be one of `"development"`, `"production"` or `"test"` depending on the [mode](#modes) the app is running in.
5273
- `BASE_URL` - this corresponds to the `baseUrl` option in `vue.config.js` and is the base path your app is deployed at.
5374

54-
## Env Variables in Index HTML
55-
56-
All resolved env variables will be available inside `public/index.html` via [lodash template interpolation](https://lodash.com/docs/4.17.5#template):
57-
58-
- `<%= VAR %>` for unescaped interpolation;
59-
- `<%- VAR %>` for HTML-escaped interpolation;
60-
- `<% expression %>` for JavaScript control flows.
61-
62-
For example, to reference static assets copied from the root of `public`, you will need to use the `BASE_URL` variable:
63-
64-
``` html
65-
<link rel="shortcut icon" href="<%= BASE_URL %>favicon.ico">
66-
```
75+
All resolved env variables will be available inside `public/index.html` as discussed in [HTML - Interpolation](./html-and-static-assets.md#interpolation).
6776

6877
## Local Only Variables
6978

0 commit comments

Comments
 (0)