my current webpack output config is as follows:
output: {
path: PATHS.build,
filename: '/[name].[chunkhash].js',
chunkFilename: '/[chunkhash].js'
}
However, I have one entry file (custom.js) that I don't want to add [chunkhash] suffix. all others I do want to add the chuckhash suffix after the file name. Essentially:
if (name is 'custom') {
filename: '/[name].js'
} else {
filename: '/[name].[chunkhash].js'
}
How can I achieve this?
From https://webpack.js.org/configuration/output/#output-filename:
module.exports = {
//...
output: {
filename: ({ chunk: { name } }) => {
return name === 'main' ? '[name].js': '[name]/[name].js';
},
}
};
You can easily do that (webpack 4.x):
output: {
filename: '[name].js',
chunkFilename: (arg) => {
if (arg.chunk.name == "vendor") {
return '[name].[chunkhash].js';
}
return '[name].js';
} ,
publicPath: `/${common.APP_ROOT}/`
},
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With