Skip to content

Add Config Section for default plugins #51

Description

@aljones15

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:

  1. As has recently been documented trying to merge the config of some plugins via WebpackConfigMerge causes issues
  2. Separates config options for plugins from index.js to config.js which increases code clarity and makes index.js cleaner
  3. Allows projects to more easily modify the WebPack Plugins this library uses by default
  4. Adheres closer to the config options seen in other bedrock libraries
  5. Reduces the need in config['bedrock-webpack'].configs for using non-json data structures such as classes

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions