您现在的位置:首页 >> 前端 >> 内容

webpack压缩图片模块教程

时间:2017/11/4 11:24:52 点击:

  核心提示:1:npm install image-webpack-loader2:require(image-webpack-loader)3:webpack.base.config 修改{test: /\.(...

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,还可以的。

Tags:WE EB BP PA 
作者:网络 来源:coder_daiw