Created
September 24, 2016 09:35
-
-
Save ecpplus/e7eb4b315dd63d8d7de9e673cf72c3fb to your computer and use it in GitHub Desktop.
Change config between environments
This file contains hidden or 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
const webpack = require('webpack'); | |
const config = { | |
entry: './source/javascripts/app.js', | |
output: { | |
filename: 'bundle.js', | |
path: './source/javascripts' | |
}, | |
module: { | |
loaders: [ | |
{ | |
test: /\.(js|es6)$/, | |
exclude: /node_modules/, | |
loader: 'babel-loader', | |
query:{ | |
presets: ['react', 'es2015'] | |
} | |
} | |
] | |
}, | |
devtool: ['cheap-module-source-map'], | |
plugins: [ | |
new webpack.DefinePlugin({ | |
'process.env': { | |
'NODE_ENV': JSON.stringify(process.env.NODE_ENV) | |
} | |
}), | |
], | |
} | |
if (process.env.NODE_ENV === 'production') { | |
config.plugins.push( | |
new webpack.optimize.UglifyJsPlugin({ | |
compress: { | |
screw_ie8: true, | |
warnings: false, | |
} | |
}) | |
) | |
} else { | |
config.devtool = "#cheap-module-source-map" | |
} | |
module.exports = config |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment