ly 2 anni fa
parent
commit
047eed1888
2 ha cambiato i file con 21 aggiunte e 0 eliminazioni
  1. 1 0
      ui/package.json
  2. 20 0
      ui/vue.config.js

+ 1 - 0
ui/package.json

@@ -46,6 +46,7 @@
     "axios": "^0.21.1",
     "clipboard": "2.0.4",
     "core-js": "3.6.5",
+    "compression-webpack-plugin": "5.0.2",
     "dayjs": "^1.10.6",
     "echarts": "4.2.1",
     "echarts-liquidfill": "^3.1.0",

+ 20 - 0
ui/vue.config.js

@@ -4,6 +4,7 @@ const defaultSettings = require('./src/settings.js')
 function resolve(dir) {
   return path.join(__dirname, dir)
 }
+const CompressionPlugin = require('compression-webpack-plugin')
 
 const name = defaultSettings.title || 'CPMS管理系统' // 标题
 
@@ -45,6 +46,25 @@ module.exports = {
     },
     disableHostCheck: true
   },
+
+  configureWebpack: {
+    name: name,
+    resolve: {
+      alias: {
+        '@': resolve('src')
+      }
+    },
+    plugins: [
+      new CompressionPlugin({
+        test: /\.(js|css|html)?$/i,     // 压缩文件格式
+        filename: '[path].gz[query]',   // 压缩后的文件名
+        algorithm: 'gzip',              // 使用gzip压缩
+        threshold: 10240,               // 对超过10K的数据压缩
+        minRatio: 0.8                   // 压缩率小于1才会压缩
+      })
+    ],
+  },
+
   chainWebpack(config) {
     //去除打包后缀的hash值
     // config.output.filename('static/js/[name].js').end();