npm install --save-dev compression-webpack-plugin@1.11.2
在config/index.js中配置:
在webpack.conf.js(或者webpack.prod.conf.js)中修改:
打包结果:
在nginx中配置:
nginx reload后如果提示没有gz_static模块,则需要重新编译安装nginx,如下:
./configure --with-http_gzip_static_module
如果之前安装时有其他的参数设置,需要把其他的参数也带上 ./nginx -V查看
然后make&&make install
f12查看network的请求结果是否正确