webpack打包gz文件,nginx开启gzip压缩

wepback配置

webpack4配合"compression-webpack-plugin": "^6.1.2"打包压缩gz

typescript 复制代码
chain.plugin("compression").use(
        new CompressionPlugin({
          test: /\.js$|\.html$|\.css$/,
          threshold: 10240, // 超过10KB的压缩
          deleteOriginalAssets: false,// 保留源文件
        })
      )

上传文件到服务器

nginx配置

typescript 复制代码
location /h5/ {
		gzip on;	// 动态压缩,如果没有gz文件再压缩
		gzip_static on;// 优先返回静态gz文件
		gzip_http_version 1.1;
		gzip_proxied expired no-cache no-store private auth;
		gzip_vary on;
		gzip_types text/plain application/javascript text/css application/xml text/javascript application/x-httpd-php image/jpeg image/gif image/png;
        add_header Cache-Control no-store;
        index  index.html;
        }
相关推荐
Tyler_11 分钟前
iOS PlayWright mcp server
前端·ios·ai编程
嘟嘟07179 分钟前
从零理解 MCP:手写一个本地 MCP Server 并接入 LangChain Agent
前端·后端
cocoafei11 分钟前
GPT-5.6 后,别再混淆 ChatGPT 和 Codex 额度了
前端·人工智能·chatgpt
你怎么知道我是队长12 分钟前
JavaScript的函数介绍
开发语言·前端·javascript
weedsfly16 分钟前
观察者模式 vs 发布-订阅模式:从概念到实战,一次讲清楚
前端·javascript·面试
暗不需求17 分钟前
手写 AJAX:从 XMLHttpRequest 到封装一个简易 axios
前端·面试
小南家的青蛙18 分钟前
使用Nginx中配置CRL
nginx·crl
cxxcode21 分钟前
CSS Loader 与样式处理链路
前端·css
电商API_1800790524722 分钟前
电商ERP 自动同步订单功能实现拆解与技术手段
服务器·前端·网络·爬虫
cxxcode22 分钟前
CSS 隔离与 qiankun 样式问题总结
前端