Skip to content

Instantly share code, notes, and snippets.

@lgraubner
Created June 9, 2017 20:03
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save lgraubner/809b9c806c82366af34193ade5cfeb57 to your computer and use it in GitHub Desktop.
Save lgraubner/809b9c806c82366af34193ade5cfeb57 to your computer and use it in GitHub Desktop.
Webpack image processing sample configuration
const webpackConfig = {
entry: './app/index.js',
output: {
filename: 'bundle.js',
path: path.resolve(__dirname, 'dist')
},
module: {
rules: [
{
test: /\.css$/,
loader: 'style-loader'
},
{
test: /.*\.(gif|png|jpe?g)$/i,
use: [
{
loader: 'url-loader',
options: {
limit: 8000,
name: '/images/[name]_[sha512:hash:base64:7].[ext]'
}
},
{
loader: 'image-webpack-loader',
options: {
optipng: {
optimizationLevel: 7
},
pngquant: {
quality: '65-90'
},
mozjpeg: {
quality: 65
}
}
}
]
}
]
}
};
module.exports = webpackConfig;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment