Currently we have 8 default plugins:
|
plugins: [ |
|
...webpackHtmlPlugin, |
|
...webpackDefinePlugin, |
|
...webpackCleanPlugin, |
|
new VueLoaderPlugin(), |
|
...webpackProgressPlugin, |
|
...webpackHmrPlugin |
|
], |
|
minimizer: [new TerserPlugin(terserOptions)] |
|
if(command.webpackStats === 'true') { |
|
baseConfig.plugins.push(new StatsPlugin('webpack-stats.json', { |
|
chunkModules: true |
|
})); |
|
} |
the proposal is to create a new section in this library's config file which exposes the settings for these Plugins.
This would allow projects to modify the plugin settings if needed.
Add:
config['bedrock-webpack'].pluginOptions = {
cleanWebpackPlugin: {
},
htmlWebpackPlugin: {
template: path.join(__dirname, '..', 'templates', 'index.html')
},
statsPlugin: {
},
terserPlugin: {
},
vueLoaderPlugin: {
},
progressPlugin: {
},
hotModuleReplacementPlugin: {
},
cleanWebpackPlugin: {
}
}
Then inside of index.js simply reference this when creating a plugin.
new CleanWebpackPlugin(config.pluginOptions.cleanWebpackPlugin);
Why:
- As has recently been documented trying to merge the config of some plugins via WebpackConfigMerge causes issues
- Separates config options for plugins from index.js to config.js which increases code clarity and makes index.js cleaner
- Allows projects to more easily modify the WebPack Plugins this library uses by default
- Adheres closer to the config options seen in other bedrock libraries
- Reduces the need in
config['bedrock-webpack'].configs for using non-json data structures such as classes
Currently we have 8 default plugins:
bedrock-webpack/lib/index.js
Lines 393 to 400 in 5d4834f
bedrock-webpack/lib/index.js
Line 460 in 5d4834f
bedrock-webpack/lib/index.js
Lines 483 to 487 in 5d4834f
the proposal is to create a new section in this library's config file which exposes the settings for these Plugins.
This would allow projects to modify the plugin settings if needed.
Add:
Then inside of
index.jssimply reference this when creating a plugin.Why:
config['bedrock-webpack'].configsfor using non-json data structures such as classes