Skip to content

Instantly share code, notes, and snippets.

@MrCoffey
Last active August 7, 2016 04:21
Show Gist options
  • Save MrCoffey/6d3d09d2cae052aad8d6f227365ab843 to your computer and use it in GitHub Desktop.
Save MrCoffey/6d3d09d2cae052aad8d6f227365ab843 to your computer and use it in GitHub Desktop.
My base webpack configuration
var debug = process.env.NODE_ENV !== "production";
var webpack = require('webpack');
var path = require('path');
module.exports = {
context: path.join(__dirname, "client"),
devtool: debug ? "inline-sourcemap" : null,
entry: [
"./js/app.js",
'webpack/hot/dev-server',
'webpack-dev-server/client?http://localhost:8080/'
],
module: {
loaders: [
{
test: /\.jsx?$/,
exclude: /(node_modules|bower_components)/,
loader: 'babel-loader',
query: {
presets: ['react', 'es2015'],
plugins: ['react-html-attrs', 'transform-class-properties', 'transform-decorators-legacy'],
}
}
]
},
output: {
path: __dirname + "/client/dist/",
filename: "app.min.js"
},
plugins: debug ? [] : [
new webpack.DefinePlugin({
'process.env':{
'NODE_ENV': JSON.stringify('production')
}
}),
new webpack.optimize.DedupePlugin(),
new webpack.optimize.OccurenceOrderPlugin(),
new webpack.optimize.UglifyJsPlugin({ mangle: false, sourcemap: false }),
new webpack.HotModuleReplacementPlugin()
],
};
// ./node_modules/.bin/webpack-dev-server --content-base=client/dist --inline --watch --hot
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment