Skip to content

Instantly share code, notes, and snippets.

@kilgarenone
Created October 6, 2019 13:49
Show Gist options
  • Save kilgarenone/1873e1f19d2ea06d0cde8f15b1b2aac1 to your computer and use it in GitHub Desktop.
Save kilgarenone/1873e1f19d2ea06d0cde8f15b1b2aac1 to your computer and use it in GitHub Desktop.
webpack image loader
module.exports = {
module: {
rules: [{
test: /\.(png|jpe?g)$/i,
use: [
{
loader: "file-loader",
options: {
name: `img/[name].[hash].[ext]`
}
},
{
loader: "img-loader",
options: {
plugins: [
require("imagemin-mozjpeg")({
quality: 80,
progressive: true,
arithmetic: false
}),
require("imagemin-pngquant")({
speed: 10,
strip: true,
quality: [0.3, 0.5]
})
]
}
}
]
}]
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment