Created
June 21, 2016 16:27
-
-
Save obihann/815b1c925d6bd0a09816b9fb58be23b3 to your computer and use it in GitHub Desktop.
Production ready webpack config for images, es2015/babel/react js/jsx, and sass/scss
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
var autoprefixer = require('autoprefixer'); | |
const webpack = require('webpack'); | |
module.exports = { | |
output: { | |
path: __dirname + "/dist", | |
filename: "bundle.js" | |
}, | |
module: { | |
loaders: [ | |
{ | |
test: /\.(jpe?g|png|gif|svg)$/i, | |
loaders: [ | |
'file?hash=sha512&digest=hex&name=[hash].[ext]', | |
'image-webpack?bypassOnDebug&optimizationLevel=7&interlaced=false' | |
] | |
}, | |
{ | |
test: /\.css$/, | |
loader: "style!css?sourceMap!postcss-loader" | |
}, | |
{ | |
test: /\.scss$/, | |
loaders: ["style", "css", "sass", "postcss-loader"] | |
}, | |
{ | |
test: /\.jsx?$/, | |
exclude: /(node_modules|bower_components)/, | |
loader: 'babel', | |
query: { | |
presets: ['es2015', 'react'] | |
} | |
} | |
] | |
}, | |
postcss: [ autoprefixer({ browsers: ['last 2 versions'] }) ], | |
plugins: [ | |
new webpack.DefinePlugin({ | |
'process.env': { | |
'NODE_ENV': JSON.stringify('production') | |
} | |
}), | |
new webpack.optimize.UglifyJsPlugin({ | |
minimize: true, | |
compress: { | |
unused: true, | |
dead_code: true, | |
warnings: false, | |
screw_ie8: true | |
}, | |
compress: { | |
warnings: false | |
} | |
}) | |
], | |
}; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment