Skip to content

doesn't respect webpack configuration if more than one is exported #56

Open

Description

@dubitabam

If you export more than one configuration, onBuildEnd is fired after the first configuration is processed even if that configuration uses no plugins.
Also the last onBuildEnd definition overwrites all previously defined.

node 8.7.0
webpack 3.8.1
webpack-shell-plugin 0.5.0

module.exports = [{
    entry: {
        client: ['./client.ts']
    },
    // will never fire..
    plugins: [new WebpackShellPlugin({ onBuildEnd: ['echo "fin client"'] })],
    ...
}, {
    entry: {
        server: ['./server.ts']
    },
    // will fire when client is finished
    plugins: [new WebpackShellPlugin({ onBuildEnd: ['echo "fin server"'] })],
    ...
}];

Activity

  1. quilicicf commented on Jun 14, 2018

    @quilicicf

    Stumbled upon the second issue too (the last definition of onBuildEnd overwrites the previously defined one).
    I was doing something like this:

    In webpack.config.js:

    const webpackConfigDev = require('./webpack/webpack.config.dev');
    const webpackConfigProd = require('./webpack/webpack.config.prod');
    const ENV = { DEV: 'dev', PROD: 'prod' };
    
    module.exports = ({ NODE_ENV = ENV.DEV }) => {
      switch (NODE_ENV) {
        case ENV.DEV:
          return webpackConfigDev;
    
        case ENV.PROD:
          return webpackConfigProd;
    
        default:
          throw Error(`Unknown environment ${NODE_ENV}`);
      }
    };

    In webpack/webpack.config.dev.js:

    const WebpackShellPlugin = require('webpack-shell-plugin');
    const baseConfig = require('./webpack.config.base');
    
    module.exports = {
      ...baseConfig,
      plugins: [
        ...baseConfig.plugins,
        new WebpackShellPlugin({
          onBuildEnd: `do dev-related things`,
        }),
      ],
    };

    In webpack/webpack.config.prod.js:

    const WebpackShellPlugin = require('webpack-shell-plugin');
    const baseConfig = require('./webpack.config.base');
    
    module.exports = {
      ...baseConfig,
      plugins: [
        ...baseConfig.plugins,
        new WebpackShellPlugin({
          onBuildEnd: `do prod-related things`,
        }),
      ],
    };

    And the last required config was overriding the plugin's configuration.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions