Qukatie 1 year ago
parent
commit
7168e7ddae
2 changed files with 24 additions and 10 deletions
  1. 1 1
      package.json
  2. 23 9
      vue.config.js

+ 1 - 1
package.json

@@ -15,7 +15,7 @@
     "axios": "^0.18.0",
     "babel-polyfill": "^6.26.0",
     "classlist-polyfill": "^1.2.0",
-    "compression-webpack-plugin": "^11.1.0",
+    "compression-webpack-plugin": "^5.0.1",
     "crypto-js": "^4.0.0",
     "echarts": "^5.2.2",
     "element-ui": "^2.15.1",

+ 23 - 9
vue.config.js

@@ -1,20 +1,33 @@
+// const webpack = require('webpack')
+// const CompressionWebpackPlugin = require('compression-webpack-plugin')
+// const productionGzipExtensions = ['js', 'css']
+
 module.exports = {
   configureWebpack: {
     externals: {
       'AMap': 'AMap' // 高德地图JS API
-    }
+    },
+    // 启用gzip
+    // plugins: [
+    //   new CompressionWebpackPlugin({
+    //     algorithm: 'gzip',
+    //     test: new RegExp('\\.(' + productionGzipExtensions.join('|') + ')$'),
+    //     threshold: 10240,
+    //     minRatio: 0.8,
+    //     deleteOriginalAssets: false // 是否删除源文件
+    //   }),
+    //   new webpack.optimize.LimitChunkCountPlugin({
+    //     maxChunks: 5, 
+    //     minChunkSize: 100
+    //   })
+    // ]
+    // 启用gzip
   },
   //路径前缀
   publicPath: "/",
   lintOnSave: true,
   productionSourceMap: false,
   chainWebpack: (config) => {
-    // 开启压缩js代码
-    config.optimization.minimize(true)
-    // 开启代码分割
-    config.optimization.splitChunks({
-      chunks: 'all',
-    });
     //忽略的打包文件
     config.externals({
       'vue': 'Vue',
@@ -38,10 +51,11 @@ module.exports = {
       '/api': {
         //本地服务接口地址
         // target: 'http://192.168.3.64:1080',
-        target: 'http://192.168.8.105:1080',
+        // target: 'http://192.168.8.105:1080',
         // target: 'http://127.0.0.1:1080',
         // 打包地址
-        // target: 'http://121.37.83.47:10004',//服务器ip
+        target: 'http://121.37.83.47:10004',//服务器ip
+        // target: 'http://192.168.161.11:10004',//服务器ip
         // target: 'http://trade.tubaosoft.com:10004',//服务器域名
         ws: true,
         pathRewrite: {