npm run build 文件过大
打包生成文件:

浏览器访问效果:

第一步:Nginx开启gzip (配置完切记重启nginx)

后台配置nginx.config。关于gzip压缩代码:

http {
  gzip on; #开启或关闭gzip on off
  gzip_disable "msie6"; #不使用gzip IE6
  gzip_min_length 100k; #gzip压缩最小文件大小,超出进行压缩(自行调节)
  gzip_buffers 4 16k; #buffer 不用修改
  gzip_comp_level 3; #压缩级别:1-10,数字越大压缩的越好,时间也越长
  gzip_types text/plain application/x-javascript text/css application/xml text/javascript application/x-httpd-php image/jpeg image/gif image/png; # 压缩文件类型
  gzip_vary off; #跟Squid等缓存服务有关,on的话会在Header里增加 "Vary: Accept-Encoding"
}

第二部:vue项目中config/index.js

productionGzip: true, //是否开启gizp压缩
productionGzipExtensions: ['js', 'css'],

开启后cnpm run build 会生成*.gz文件。
像这样:

如何识别gzip与非gzip请求

gzip请求:

非gzip请求:

gzip与非gzip在响应头中区别就是Content-Encoding是否表明是gzip压缩格式。