Skip to content

Instantly share code, notes, and snippets.

@4knort
Last active March 6, 2017 09:40
Show Gist options
  • Save 4knort/522531e37dd5be6edffdf57d18738e62 to your computer and use it in GitHub Desktop.
Save 4knort/522531e37dd5be6edffdf57d18738e62 to your computer and use it in GitHub Desktop.
'use strict'
const path = require('path');
const webpack = require('webpack');
const production = process.env.NODE_ENV === 'production';
const loaders = [
{
test: /\.(js|jsx)$/,
loader: 'babel',
include: path.join(__dirname, 'src'),
exclude: /node_modules/,
}
]
module.exports = {
entry: './home',
output: {
filename: 'bundle.js'
},
watch: !production ,
devtool: production ? 'cheap-module-source-map' : 'eval',
plugins: [
new webpack.DefinePlugin({
new webpack.DefinePlugin({
'process.env': { NODE_ENV: JSON.stringify(process.env.NODE_ENV) }
}),
new webpack.noErrorsPlugin(),
]
resolve: {
root: [
path.resolve(__dirname, 'src'),
path.resolve(__dirname, 'node_modules'),
],
extensions: ['', '.js', '.jsx'],
},
module: { loaders },
}
if(production) {
module.exports.plugins.push(
new webpack.optimize.UglifyJsPlugin({
beautify: false,
comments: false,
compress: {
sequences: true,
booleans: true,
loops: true,
unused: false,
warnings: false,
drop_console: true,
unsafe: true,
},
}),
)
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment