You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: docs/config/README.md
+4Lines changed: 4 additions & 0 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -98,6 +98,10 @@ module.exports = {
98
98
}
99
99
```
100
100
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.
Copy file name to clipboardExpand all lines: docs/dev-guide/plugin-dev.md
+8Lines changed: 8 additions & 0 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -282,6 +282,14 @@ Alternatively, the user can skip the prompts and directly initialize the plugin
282
282
vue invoke my-plugin --mode awesome
283
283
```
284
284
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>`.
Copy file name to clipboardExpand all lines: docs/guide/html-and-static-assets.md
+28-2Lines changed: 28 additions & 2 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -8,13 +8,20 @@ The file `public/index.html` is a template that will be processed with [html-web
8
8
9
9
### Interpolation
10
10
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:
12
18
13
19
```html
14
20
<linkrel="icon"href="<%= BASE_URL %>favicon.ico">
15
21
```
16
22
17
-
See also: [baseUrl](../config/#baseurl)
23
+
See also:
24
+
-[baseUrl](../config/#baseurl)
18
25
19
26
### Preload
20
27
@@ -32,6 +39,25 @@ By default, a Vue CLI app will automatically generate prefetch hints for all Jav
32
39
33
40
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')`.
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.
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
+
39
60
## Using Env Variables in Client-side Code
40
61
41
62
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
51
72
-`NODE_ENV` - this will be one of `"development"`, `"production"` or `"test"` depending on the [mode](#modes) the app is running in.
52
73
-`BASE_URL` - this corresponds to the `baseUrl` option in `vue.config.js` and is the base path your app is deployed at.
53
74
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:
All resolved env variables will be available inside `public/index.html` as discussed in [HTML - Interpolation](./html-and-static-assets.md#interpolation).
0 commit comments