How to set webpackChunkName to import () globally?

Since Webpack@3.0.0 we have this wonderful feature that allows named chunk files:

import(
  /* webpackChunkName: "my-chunk-name" */
  /* webpackMode: "lazy-once" */
  'module'
);

However, I am at a point where I have 40 such imported imports, and changing each of them is a bit of a hassle.

Is there a way to define webpackChunkNameand webpackModeglobally for all the pieces?

I present 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
}
+4
source share

Source: https://habr.com/ru/post/1680648/


All Articles