首页 > 其他分享 >Angular 打包 js文件 过大

Angular 打包 js文件 过大

时间:2022-10-08 23:11:59浏览次数:44  
标签:WebData application 1.18 js nginx conf gzip Angular 打包

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

 

标签:WebData,application,1.18,js,nginx,conf,gzip,Angular,打包
From: https://www.cnblogs.com/xiaoruilin/p/16770611.html

相关文章

  • Vue3组件库打包指南,一次生成esm、esm-bundle、commonjs、umd四种格式
    本文为Varlet组件库源码主题阅读系列第二篇,读完本篇,你可以了解到如何将一个Vue3组件库打包成各种格式上一篇里提到了启动服务前会先进行一下组件库的打包,运行的命令为:v......
  • js原生ajax发起的请求xhr
    使用xhr发起GET请求步骤:发起一个GET请求例子://1、创建一个xhr对象varxhr=newXMLHttpRequest();//2、调用xhr.open()函数请求方式获取地址xhr.open('GET','htt......
  • #yyds干货盘点#慎用JSON.stringfy
    项目中遇到一个bug,一个组件为了保留一份JSON对象,使用JSON.stringify将其转换成字符串,这样做当然是为了避免对象是引用类型造成数据源的污染。但发现后面使用JSON.pars......
  • js 日期格式化
    用法://2022-10-0622:01:09formatDate("yyyy-MM-ddhh:mm:ss",newDate());//2022-10-0622:01:09dateFormat("yyyy-MM-ddhh:mm:ss",newDate(1665064915000));......
  • JSON语法格式
    javascript作用:改变HTML内容JavaScript内嵌于HTML网页中,通过浏览器内置的JavaScript引擎进行解释执行,把一个原本只用来显示的页面转变成支持用户交互的页面程序。Javascr......
  • js字符串
    字符串声明1.直接声明 varstr='hello'2.使用new关键字(会开辟新的内存空间)varstr=newString('hello')newString和String的区别 前者开辟空间后者只是进行......
  • maven打包提示子模块的程序包不存在问题解决
    有些utils和common的模块,已经有依赖,并能正常在Idea上跑了,但打包时提示程序包xxx不存在时,在pom上加上以下代码即可:<build><plugins><plugin><......
  • video.js使用总结
    video.js使用总结video.js是通过HTML5将原生的video标签进行渲染的js开源工具。拥有更多的API,进行个性化定制。在vue项目中引入video.jspackage.json:"dependencies":......
  • vue.js3:用el-loading显示加载动画([email protected] / [email protected])
    一,el-loading1,文档地址:https://element-plus.gitee.io/zh-CN/component/loading.html2, 查看element-plus的版本:liuhongdi@lhdpc:/data/vue/imgtouch$npmlist......
  • net中c#教程 Json字符串的常用操作
    json字符串格式的出现,大大地方便了不同系统间的数据传输,无论是Net项目还是Java项目都适用。今天就分享几个json的常用操作。我们是基于Newtonsoft.Json这个第三方类库实现......