const webpack = require('webpack'); const path = require('path'); const NODE_ENV = process.env.NODE_ENV || 'development'; module.exports = { entry: { app: "./src/js/app.js" }, output: { path: path.join(__dirname, "build/js"), filename: NODE_ENV === 'development' ? '[name].js' : '[name].[id].[chunkhash].js', library: '[name]' }, module: { loaders: [ { test: /\.js$/, exclude: /(node_modules|bower_components)/, use: { loader: 'babel-loader', options: { presets: [ ["env", { "targets": { "browsers": ["last 2 versions", "safari >= 7"] } }] ] } } } ] }, plugins: [ new webpack.DefinePlugin({ 'process.env': { 'NODE_ENV': JSON.stringify(NODE_ENV) } }) ], watch: NODE_ENV === 'development', devtool: NODE_ENV === 'development' ? 'source-map' : false }; if (NODE_ENV === 'production') { module.exports.plugins.push( new webpack.optimize.UglifyJsPlugin({ compress: { warnings: false, drop_console: true, unsafe: true } }) ); }