Angular 打包 js文件 过大
1、加了--prod参数后,angular-cli会把用不到的包都删掉
//package.json 中 "scripts": { ... "build": "ng build --prod" ... }
2、nginx开启gzip优化、在nginx中server或http内上,添加这段代码
gzip on; gzip_static on; gzip_comp_level 2; gzip_http_version 1.0; gzip_proxied any; gzip_min_length 1100; gzip_buffers 16 8k; gzip_types text/plain application/javascript application/x-javascript text/css application/xml text/javascript application/x-httpd-php image/jpeg image/gif image/png; # Disable for IE < 6 because there are some known problems gzip_disable "MSIE [1-6].(?!.*SV1)"; # Add a vary header for downstream proxies to avoid sending cached gzipped files to IE6 gzip_vary on;
nginx 报错:
C:\WebData\nginx-1.18.0>nginx.exe -t nginx: [warn] the "ssl" directive is deprecated, use the "listen ... ssl" directive instead in C:\WebData\nginx-1.18.0/conf/nginx.conf:138 nginx: [emerg] unknown directive "锘縮erver" in C:/WebData/nginx-1.18.0/conf/conf.d/familyxiaomobile.conf:1 nginx: configuration file C:\WebData\nginx-1.18.0/conf/nginx.conf test failed
原因是其中一个文件格式为utf-8 +BOM 的格式,另存为 utf-8 就对了