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 就对了

 

posted @   三瑞  阅读(302)  评论(0编辑  收藏  举报
相关博文:
阅读排行:
· 分享一个免费、快速、无限量使用的满血 DeepSeek R1 模型,支持深度思考和联网搜索!
· 基于 Docker 搭建 FRP 内网穿透开源项目(很简单哒)
· ollama系列01:轻松3步本地部署deepseek,普通电脑可用
· 25岁的心里话
· 按钮权限的设计及实现
历史上的今天:
2020-10-08 微信公共账号开发:48001 api unauthorized解决
2020-10-08 windows 如何查看端口占用情况
2017-10-08 VirtualBox虚拟机网络设置(四种方式)
点击右上角即可分享
微信分享提示