Last active
March 6, 2017 09:40
-
-
Save 4knort/522531e37dd5be6edffdf57d18738e62 to your computer and use it in GitHub Desktop.
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
'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