Since Webpack@3.0.0 we have this great feature which enables named chunk files:
import(
/* webpackChunkName: "my-chunk-name" */
/* webpackMode: "lazy-once" */
'module'
);
However, I'm at the point where I have 40 imports like this and changing each one of them is kind of a hassle.
Is there any way to define webpackChunkName
and webpackMode
globally for all chunks?
I imagine something like this in webpack.config.js
:
output: {
filename: 'js/[name].js',
chunkFilename: 'js/[filename].js' // so that import('module') creates module.js
chunkMode: 'lazy-once' // so I can override default `lazy` option once and for all
}