Created
October 6, 2019 13:49
-
-
Save kilgarenone/1873e1f19d2ea06d0cde8f15b1b2aac1 to your computer and use it in GitHub Desktop.
webpack image loader
This file contains 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
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