Skip to content

Instantly share code, notes, and snippets.

@atmd83
Created July 15, 2016 11:26
Show Gist options
  • Save atmd83/6faa9b03b118dc796a11c095b144ca7f to your computer and use it in GitHub Desktop.
Save atmd83/6faa9b03b118dc796a11c095b144ca7f to your computer and use it in GitHub Desktop.
happypack
/* this file is not transpiled through babel and some installs of node are v0.x */
/* eslint-disable no-console, no-var, prefer-template */
// 3rd party modules
var path = require('path');
var webpack = require('webpack');
var HappyPack = require('happypack');
// implementation
var buildMode = process.env.NODE_ENV || 'production';
// public
module.exports = {
entry: './src/app/index.js',
devtool: 'source-map',
output: {
filename: 'app.js',
path: './dist'
},
devServer: {
contentBase: './dist',
host: '0.0.0.0',
inline: true,
port: 8083,
stats: 'errors-only'
},
module: {
loaders: [{
loader: 'happypack/loader',
test: /\.js?$/,
exclude: /(node_modules|coverage|target)/,
cacheDirectory: false
}, {
test: /\.svg$/,
include: /assets/,
loader: 'svg-inline'
}, {
test: /\.json$/,
loader: 'json'
}]
},
resolve: {
root: [
path.resolve('./src'),
path.resolve('./node_modules')
]
},
plugins: [
new HappyPack({
loaders: [ 'babel?presets[]=babel-fast-presets/es2015-stage1,presets[]=react' ]
})
]
};
if (buildMode === 'production') {
module.exports.plugins.push(
new webpack.optimize.UglifyJsPlugin({
compress: {
warnings: false
}
})
);
module.exports.plugins.push(
new webpack.optimize.DedupePlugin()
);
module.exports.plugins.push(
new webpack.optimize.AggressiveMergingPlugin()
);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment