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
+7-53Lines changed: 7 additions & 53 deletions
Original file line number
Diff line number
Diff line change
@@ -83,6 +83,13 @@ module.exports = {
83
83
84
84
Specify the output path for the generated `index.html` (relative to `outputDir`). Can also be an absolute path.
85
85
86
+
### filenameHashing
87
+
88
+
- Type: `boolean`
89
+
- Default: `true`
90
+
91
+
By default, generated static assets contains hashes in their filenames for better caching control. However, this requires the index HTML to be auto-generated by Vue CLI. If you cannot make use of the index HTML generated by Vue CLI, you can disable filename hashing by setting this option to `false`.
92
+
86
93
### pages
87
94
88
95
- Type: `Object`
@@ -365,56 +372,3 @@ See [@vue/cli-plugin-e2e-cypress](https://github.com/vuejs/vue-cli/tree/dev/pack
365
372
### Nightwatch
366
373
367
374
See [@vue/cli-plugin-e2e-nightwatch](https://github.com/vuejs/vue-cli/tree/dev/packages/%40vue/cli-plugin-e2e-nightwatch) for more details.
368
-
369
-
## Example Configurations
370
-
371
-
### Disable Hashed Filenames
372
-
373
-
While generated static asset filenames contain a hash to [ensure the browser picks up changed files](https://webpack.js.org/guides/caching/#output-filenames) this can be disabled. One common scenario for this is when integrating Vue with a backend that dictates a code structure other than what Vue CLI generates, such as with WordPress or Laravel. To disable the hashed filenames, the following can be added to [`vue.config.js`](#vue-config-js):
When manually overwriting `filename` or `chunkFilename`, `assetsDir` does not need to be included in their path values.
401
-
:::
402
-
403
-
### Disable Generating index.html
404
-
405
-
When using Vue CLI with an existing backend, you may need to disable the generation of `index.html` so that they generated assets can be used with another default document. To do so, the following can be added to [`vue.config.js`](#vue-config-js):
406
-
407
-
```js
408
-
// vue.config.js
409
-
module.exports= {
410
-
chainWebpack:config=> {
411
-
config.plugins.delete('html')
412
-
config.plugins.delete('preload')
413
-
config.plugins.delete('prefetch')
414
-
}
415
-
}
416
-
```
417
-
418
-
::: warning
419
-
[Modern Mode](../guide/browser-compatibility.md#modern-mode) will not work when the `html-webpack-plugin` is disabled.
Copy file name to clipboardExpand all lines: docs/guide/html-and-static-assets.md
+26Lines changed: 26 additions & 0 deletions
Original file line number
Diff line number
Diff line change
@@ -70,6 +70,32 @@ webpack's runtime will inject prefetch links when the parent chunk is loaded.
70
70
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 and manually select chunks to prefetch.
71
71
:::
72
72
73
+
### Disable Index Generation
74
+
75
+
When using Vue CLI with an existing backend, you may need to disable the generation of `index.html` so that the generated assets can be used in a server-rendered page. To do so, the following can be added to [`vue.config.js`](#vue-config-js):
76
+
77
+
```js
78
+
// vue.config.js
79
+
module.exports= {
80
+
// disable hashes in filenames
81
+
filenameHashing:false,
82
+
// delete HTML related webpack plugins
83
+
chainWebpack:config=> {
84
+
config.plugins.delete('html')
85
+
config.plugins.delete('preload')
86
+
config.plugins.delete('prefetch')
87
+
}
88
+
}
89
+
```
90
+
91
+
However, this is not really recommended because:
92
+
93
+
- Hard-coded file names makes it more difficult to implement efficient cache control.
94
+
- Hard-coded file names also do not play well with code-splitting, which generates additional JavaScript files with varying filenames.
95
+
- Hard-coded file names do not work with [Modern Mode](../guide/browser-compatibility.md#modern-mode).
96
+
97
+
Instead, you should consider using the [indexPath](../config/#indexpath) option to use the generated HTML as a view template in your server-side framework.
98
+
73
99
### Building a Multi-Page App
74
100
75
101
Not every app has to be an SPA. Vue CLI supports building a multi-paged app using the [`pages` option in `vue.config.js`](../config/#pages). The built app will efficiently share common chunks between multiple entries for optimal loading performance.
0 commit comments