webpack-shell-plugin
webpack-shell-plugin copied to clipboard
doesn't respect webpack configuration if more than one is exported
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"'] })],
...
}];
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.