Skip to content

Instantly share code, notes, and snippets.

@Haegin
Created January 15, 2016 19:50
Show Gist options
  • Save Haegin/f33be8eca8d4c044d264 to your computer and use it in GitHub Desktop.
Save Haegin/f33be8eca8d4c044d264 to your computer and use it in GitHub Desktop.
var webpack = require('webpack');
var path = require('path');
var CompressionPlugin = require("compression-webpack-plugin");
var HtmlWebpackPlugin = require('html-webpack-plugin');
var ExtractTextPlugin = require('extract-text-webpack-plugin');
var Clean = require('clean-webpack-plugin');
module.exports = {
entry: {
app: ['./application.jsx'],
},
output: {
path: path.join(__dirname, 'dist', 'production', 'public'),
filename: 'javascripts/bundle.[chunkhash].js',
},
module: {
loaders: [
{
test: /\.(jsx|es6|js)$/,
exclude: /(node_modules|bower_components)/,
loader: 'babel'
},
{
test: /\.scss$/,
loader: ExtractTextPlugin.extract('css!sass', {publicPath: "stylesheets/"})
},
{
test: /\.woff$/,
loader: 'url-loader',
query: {
limit: 5000,
name: 'fonts/[hash].[ext]'
}
}
]
},
stats: {
colors: true,
reasons: true,
},
plugins: [
new Clean(['dist/production']),
new webpack.ProvidePlugin({
'fetch': 'imports?this=>global!exports?global.fetch!whatwg-fetch',
React: 'react/addons'
}),
new webpack.DefinePlugin({
'process.env': {
'NODE_ENV': JSON.stringify('production') // This affects react lib size
}
}),
new webpack.optimize.UglifyJsPlugin({
compress: {
warnings: false,
},
}),
new ExtractTextPlugin("stylesheets/styles.[chunkhash].css"),
new HtmlWebpackPlugin({
template: "index-template.html",
inject: "body"
}),
new CompressionPlugin({
asset: "{file}.gz",
algorithm: "gzip",
regExp: /\.(js|html|css)$/,
threshold: 10240,
minRatio: 0.8
}),
]
};
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment