Instantly share code, notes, and snippets.

Embed
What would you like to do?
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