Skip to content

Instantly share code, notes, and snippets.

@hckhanh
Created December 5, 2016 03:36
Show Gist options
  • Save hckhanh/745be6c8723bfff10ab0699bc99b8a2d to your computer and use it in GitHub Desktop.
Save hckhanh/745be6c8723bfff10ab0699bc99b8a2d to your computer and use it in GitHub Desktop.
const webpack = require('webpack');
const ExtractTextPlugin = require('extract-text-webpack-plugin');
const HtmlWebpackPlugin = require('html-webpack-plugin');
module.exports = {
entry: [ 'whatwg-fetch', './js/app.js' ],
// Render source-map file for final build
devtool: 'source-map',
output: {
filename: '[name].js',
path: __dirname + '/dist',
},
module: {
loaders: [
{
test: /\.js$/,
exclude: /node_modules/,
loader: 'babel-loader?compact=false',
},
{
test: /\.css$/,
loader: ExtractTextPlugin.extract('css-loader')
},
{
test: /\.(png|jpg|jpeg|gif|svg|woff|woff2|ttf|eot)$/,
loader: "file-loader?name=assets/[name].[ext]"
}
]
},
resolve: {
alias: {
// Bind version of jquery-ui
"jquery-ui": "jquery-ui/jquery-ui.js"
}
},
plugins: [
// Define production build to allow React to strip out unnecessary checks
new webpack.DefinePlugin({
'process.env':{
'NODE_ENV': JSON.stringify('production')
}
}),
// Minify the bundle
new webpack.optimize.UglifyJsPlugin({
compress: {
// suppresses warnings, usually from module minification
warnings: false,
drop_console: true,
collapse_vars: true,
reduce_vars: true
},
output: {
comments: false
}
}),
new webpack.ProvidePlugin({
// Automtically detect jQuery and $ as free var in modules
// and inject the jquery library
// This is required by many jquery plugins
$: 'jquery',
jQuery: 'jquery'
}),
new ExtractTextPlugin('[name].css'),
new HtmlWebpackPlugin({
template: 'index.html'
})
]
};
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment