Skip to content

Commit c6b06ec

Browse files
betweenbrainAkryum
authored andcommitted
docs: Add configuration examples section (vuejs#1779)
* Update README.md * Add warning about modern mode not working when the html-webpack-plugin is disabled
1 parent 6729880 commit c6b06ec

File tree

1 file changed

+49
-0
lines changed

1 file changed

+49
-0
lines changed

docs/config/README.md

Lines changed: 49 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -344,3 +344,52 @@ See [@vue/cli-plugin-e2e-cypress](https://github.com/vuejs/vue-cli/tree/dev/pack
344344
### Nightwatch
345345

346346
See [@vue/cli-plugin-e2e-nightwatch](https://github.com/vuejs/vue-cli/tree/dev/packages/%40vue/cli-plugin-e2e-nightwatch) for more details.
347+
348+
## Example Configurations
349+
### Disable Hashed Filenames
350+
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](https://cli.vuejs.org/config/#vue-config-js)`:
351+
352+
353+
``` js
354+
// vue.config.js
355+
module.exports = {
356+
chainWebpack: (config) => {
357+
config.module
358+
.rule('images')
359+
.use('url-loader')
360+
.tap(options => Object.assign({}, options, { name: 'img/[name].[ext]' }));
361+
},
362+
css: {
363+
extract: {
364+
filename: '/css/[name].css',
365+
chunkFilename: '/css/[name].css',
366+
},
367+
},
368+
configureWebpack: {
369+
output: {
370+
filename: 'js/[name].js',
371+
chunkFilename: 'js/[name].js',
372+
},
373+
},
374+
};
375+
```
376+
::: tip
377+
When manually overwriting `filename` or `chunkFilename`, `assetsDir` does not need to be included in their path values.
378+
:::
379+
## Disable Generating index.html
380+
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](https://cli.vuejs.org/config/#vue-config-js)`:
381+
382+
``` js
383+
// vue.config.js
384+
module.exports = {
385+
chainWebpack: config => {
386+
config.plugins.delete('html')
387+
config.plugins.delete('preload')
388+
config.plugins.delete('prefetch')
389+
}
390+
}
391+
```
392+
393+
::: warning
394+
[Modern Mode](https://cli.vuejs.org/guide/browser-compatibility.html#modern-mode) will not work when the `html-webpack-plugin` is disabled.
395+
:::

0 commit comments

Comments
 (0)