Bug report
What is the current behavior?
Currently output.chunkFilename doesn't support a function yet: https://github.com/webpack/webpack/blob/master/lib/TemplatedPathPlugin.js when reading the TemplatedPathPlugin showed that line https://github.com/webpack/webpack/blob/master/lib/TemplatedPathPlugin.js#L143 simply fills the chunkFilename with the filename if it's left empty.
const chunkFilename = outputOptions.chunkFilename || outputOptions.filename;
If the current behavior is a bug, please provide the steps to reproduce.
This works fine:
webpackConfig
.mode('production')
.devtool(options.productionSourceMap ? 'source-map' : false)
.output
.filename((chunkData) => {
return chunkData.chunk.name === 'vendor' ? 'js/[name].js': 'js/[id].[contenthash:8].js';
})
This throws an error:
webpackConfig
.mode('production')
.devtool(options.productionSourceMap ? 'source-map' : false)
.output
.chunkFilename((chunkData) => {
return chunkData.chunk.name === 'vendor' ? 'js/[name].js': 'js/[id].[contenthash:8].js';
})
Error:
WebpackOptionsValidationError: Invalid configuration object. Webpack has been initialised using a configuration object that does not match the API schema.
- configuration.output.chunkFilename should be a string.
-> The filename of non-entry chunks as relative path inside the `output.path` directory.
What is the expected behavior?
I would expect the output.chunkFilename to also allow a function if it simply works when you don't specify the option. And use a function within the output.filename property
Other relevant information:
webpack version: 4.29
Node.js version: 8.15.1
Operating System: Ubuntu 18.04.2 LTS
Bug report
What is the current behavior?
Currently
output.chunkFilenamedoesn't support a function yet: https://github.com/webpack/webpack/blob/master/lib/TemplatedPathPlugin.js when reading theTemplatedPathPluginshowed that line https://github.com/webpack/webpack/blob/master/lib/TemplatedPathPlugin.js#L143 simply fills thechunkFilenamewith thefilenameif it's left empty.If the current behavior is a bug, please provide the steps to reproduce.
This works fine:
This throws an error:
Error:
What is the expected behavior?
I would expect the
output.chunkFilenameto also allow a function if it simply works when you don't specify the option. And use a function within theoutput.filenamepropertyOther relevant information:
webpack version: 4.29
Node.js version: 8.15.1
Operating System: Ubuntu 18.04.2 LTS