Created
January 27, 2016 21:32
-
-
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
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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