Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Open
dubitabam opened this issue Nov 16, 2017 · 1 comment
Open

Comments

@dubitabam
Copy link

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"'] })],
    ...
}];
@quilicicf
Copy link

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
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants