mirror of
https://github.com/whyour/qinglong.git
synced 2025-05-23 23:06:06 +08:00
nginx增加gzip压缩,webpack预压缩gz文件
This commit is contained in:
parent
b10e77dce6
commit
1cec38243c
12
.umirc.ts
12
.umirc.ts
|
@ -1,4 +1,5 @@
|
||||||
import { defineConfig } from 'umi';
|
import { defineConfig } from 'umi';
|
||||||
|
const CompressionPlugin = require('compression-webpack-plugin');
|
||||||
|
|
||||||
export default defineConfig({
|
export default defineConfig({
|
||||||
hash: true,
|
hash: true,
|
||||||
|
@ -14,4 +15,15 @@ export default defineConfig({
|
||||||
changeOrigin: true,
|
changeOrigin: true,
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
|
chainWebpack(memo) {
|
||||||
|
memo.plugin('CompressionPlugin').use(
|
||||||
|
new CompressionPlugin({
|
||||||
|
filename: '[path][base].gz',
|
||||||
|
algorithm: 'gzip',
|
||||||
|
test: /\.js$|\.css$|\.html$/,
|
||||||
|
threshold: 10240,
|
||||||
|
minRatio: 0.8,
|
||||||
|
}),
|
||||||
|
);
|
||||||
|
},
|
||||||
});
|
});
|
||||||
|
|
|
@ -11,6 +11,15 @@ server {
|
||||||
proxy_pass http://api;
|
proxy_pass http://api;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
gzip on;
|
||||||
|
gzip_static on;
|
||||||
|
gzip_types text/plain text/css application/json application/x-javascript text/xml application/xml application/xml+rss text/javascript;
|
||||||
|
gzip_proxied any;
|
||||||
|
gzip_vary on;
|
||||||
|
gzip_comp_level 6;
|
||||||
|
gzip_buffers 16 8k;
|
||||||
|
gzip_http_version 1.1;
|
||||||
|
|
||||||
location / {
|
location / {
|
||||||
index index.html index.htm;
|
index index.html index.htm;
|
||||||
try_files $uri $uri/ /index.html;
|
try_files $uri $uri/ /index.html;
|
||||||
|
|
|
@ -57,6 +57,7 @@
|
||||||
"@types/react": "^17.0.0",
|
"@types/react": "^17.0.0",
|
||||||
"@types/react-dom": "^17.0.0",
|
"@types/react-dom": "^17.0.0",
|
||||||
"@umijs/test": "^3.3.9",
|
"@umijs/test": "^3.3.9",
|
||||||
|
"compression-webpack-plugin": "6.1.1",
|
||||||
"lint-staged": "^10.0.7",
|
"lint-staged": "^10.0.7",
|
||||||
"nodemon": "^2.0.4",
|
"nodemon": "^2.0.4",
|
||||||
"prettier": "^2.2.0",
|
"prettier": "^2.2.0",
|
||||||
|
|
Loading…
Reference in New Issue
Block a user