webpack 压缩图片模块

1:npm install image-webpack-loader

2:

require("image-webpack-loader")
3:webpack.base.config 修改

{
                test: /\.(png|jpe?g|gif|svg)(\?.*)?$/,
                loader: ['url-loader?limit=8192&name=img/[name].[hash].[ext]',
                'image-webpack-loader?{progressive:true, optimizationLevel: 7, interlaced: false, pngquant:{quality: "55-90", speed: 4}}'], 
                // options: {
                //     limit: 10000,
                //     name: utils.assetsPath('img/[name].[hash:7].[ext]')
                // }
            },
}

627k png压缩成了272,还可以的。

猜你喜欢

转载自blog.csdn.net/coder_daiwang/article/details/78437983