https://webpack.js.org/api/module-methods/#import-
import(
/* webpackChunkName: "my-chunk-name" */
'module'
);
Webpack 2 no longer let's you name your cunks generated by System.import()
or import()
. So you would get chunks
named 0.js
etc. This plugn attempts to guess the chunk name by parsing the requested filename.
If you need a more robust solution, PR are very welcome.
As a devDependency!
npm i webpack-async-chunk-names-plugin -D
yarn add webpack-async-chunk-names-plugin -D
const AsyncChunkNames = require('../index');
module.exports = {
entry: __dirname + '/entry.js',
output: {
path: __dirname + '/output',
filename: 'output.js',
chunkFilename: '[name].js'
},
plugins: [
new AsyncChunkNames()
]
};
Don't forget to set output.chunkFilename!