Skip to content

Instantly share code, notes, and snippets.

@joewalker
Created January 27, 2016 21:32
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save joewalker/ec8f58e189b97776030c to your computer and use it in GitHub Desktop.
Save joewalker/ec8f58e189b97776030c to your computer and use it in GitHub Desktop.
Keep your core webpack config simple and mutate it with ES.whatever Object Rest/Spread
import webpack from 'webpack';
import config from './webpack.config';
import { mapObject } from './web/util/util';
export const original = config;
/**
* Development config. Inspired by
* https://github.com/gaearon/react-transform-boilerplate/blob/master/webpack.config.dev.js
*/
export const development = {
...config,
debug: true,
devtool: 'source-map',
entry: mapObject(config.entry, ([ name, sources ]) => {
const newSources = [
'eventsource-polyfill', // necessary for hot reloading with IE
'webpack-hot-middleware/client',
...sources,
];
return [ name, newSources ];
}),
output: {
...config.output,
pathinfo: true,
},
plugins: [
...(config.plugins || []),
new webpack.HotModuleReplacementPlugin(),
new webpack.NoErrorsPlugin(),
],
};
/**
* Production config. Inspired by
* https://github.com/gaearon/react-transform-boilerplate/blob/master/webpack.config.prod.js
*/
export const production = {
...config,
plugins: [
...(config.plugins || []),
new webpack.optimize.OccurenceOrderPlugin(),
new webpack.DefinePlugin({
'process.env': {
NODE_ENV: JSON.stringify('production'),
},
}),
new webpack.optimize.UglifyJsPlugin({
compressor: {
warnings: false,
},
}),
],
};
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment