我想使用这个插件来压缩图片,但我遇到了这样的问题,构建通过了,但是图片没有被压缩。我是webpack新手,不理解问题出在哪里(也许我需要一个压缩文件的输出点作为文件夹?)。next.config.js。
const ImageMinimizerPlugin = require("image-minimizer-webpack-plugin");
const nextConfig = {
future: {
webpack5: true
},
webpack: (config, options) => {
config.module.rules.push({
test: /\.(jpe?g|png|svg)$/i,
type: "asset",
})
config.plugins.push(new ImageMinimizerPlugin({
minimizerOptions: {
// Lossless optimization with custom option
// Feel free to experiment with options for better result for you
plugins: [
["jpegtran", { progressive: true }],
["optipng", { optimizationLevel: 5 }],
// Svgo configuration here https://github.com/svg/svgo#configuration
[
"svgo",
{
plugins:
{
name: "removeViewBox",
active: false,
},
},
],
],
},
})
)
return config
},
};
module.exports = nextConfig