Kaynağa Gözat

vue.config.js

quwangxin 3 yıl önce
ebeveyn
işleme
3a1ac3dcf4
1 değiştirilmiş dosya ile 61 ekleme ve 0 silme
  1. 61 0
      vue.config.js

+ 61 - 0
vue.config.js

@@ -0,0 +1,61 @@
+const CompressionWebpackPlugin = require('compression-webpack-plugin');
+const { transformElementScss } = require('ele-admin/lib/utils/dynamic-theme');
+const path = require('path');
+
+function resolve (dir) {
+  return path.join(__dirname, dir);
+}
+
+module.exports = {
+  lintOnSave: false,
+  productionSourceMap: false,
+  configureWebpack: {
+    performance: {
+      maxAssetSize: 2000000,
+      maxEntrypointSize: 2000000
+    }
+  },
+  devServer: {
+    // 代理跨域的配置
+    port: 9999,
+    proxy: {
+      // 当我们的本地的请求 有/api的时候,就会代理我们的请求地址向另外一个服务器发出请求
+      '/api': {
+        // target: 'http://192.168.3.51:86', // 测试
+
+        // target: 'http://192.168.3.35:8080', // kang杨威
+        // target: 'http://192.168.3.25:8080', // 黄峥嵘
+        // target: 'http://192.168.3.41:8080', // 何江鹏
+        target: 'http://192.168.3.33:8080', // 谢一平
+
+        changeOrigin: true, // 只有这个值为true的情况下 才表示开启跨域
+        pathRewrite: {
+          '^/api': ''
+        }
+      }
+    }
+  },
+  chainWebpack (config) {
+    config.plugins.delete('prefetch');
+
+    if (process.env.NODE_ENV !== 'development') {
+      // gzip 压缩
+      config.plugin('compressionPlugin').use(
+        new CompressionWebpackPlugin({
+          test: /\.(js|css|html)$/,
+          threshold: 10240
+        })
+      );
+    }
+  },
+  css: {
+    loaderOptions: {
+      sass: {
+        sassOptions: {
+          outputStyle: 'expanded',
+          importer: transformElementScss()
+        }
+      }
+    }
+  }
+};