Преглед изворни кода

修改proxy代理到本地服务器

noob пре 3 година
родитељ
комит
de6fcfdf43
1 измењених фајлова са 46 додато и 25 уклоњено
  1. 46 25
      vue.config.js

+ 46 - 25
vue.config.js

@@ -1,31 +1,34 @@
-const CompressionPlugin = require('compression-webpack-plugin');
-const webpack = require('webpack');
-const BundleAnalyzerPlugin = require('webpack-bundle-analyzer').BundleAnalyzerPlugin
+const CompressionPlugin = require("compression-webpack-plugin");
+const webpack = require("webpack");
+const BundleAnalyzerPlugin =
+    require("webpack-bundle-analyzer").BundleAnalyzerPlugin;
 module.exports = {
-    publicPath: process.env.NODE_ENV === 'production' ? '' : '/',
+    publicPath: process.env.NODE_ENV === "production" ? "" : "/",
     productionSourceMap: false,
     lintOnSave: false,
 
-    chainWebpack: config => {
-        if (process.env.NODE_ENV === 'production') {
+    chainWebpack: (config) => {
+        if (process.env.NODE_ENV === "production") {
             if (process.env.npm_config_report) {
                 config
-                    .plugin('webpack-bundle-analyzer')
-                    .use(require('webpack-bundle-analyzer').BundleAnalyzerPlugin)
+                    .plugin("webpack-bundle-analyzer")
+                    .use(
+                        require("webpack-bundle-analyzer").BundleAnalyzerPlugin
+                    );
             }
-            config.plugins.delete('prefetch');
+            config.plugins.delete("prefetch");
         }
     },
-    configureWebpack: config => {
-        if (process.env.NODE_ENV === 'production') {
+    configureWebpack: (config) => {
+        if (process.env.NODE_ENV === "production") {
             config.optimization = {
                 splitChunks: {
-                    chunks: "all",          //async异步代码分割 initial同步代码分割 all同步异步分割都开启
-                    minSize: 10000,         //字节 引入的文件大于30kb才进行分割
+                    chunks: "all", //async异步代码分割 initial同步代码分割 all同步异步分割都开启
+                    minSize: 10000, //字节 引入的文件大于30kb才进行分割
                     // minChunks: 2,           //模块至少使用次数
                     // maxAsyncRequests: 25,    //同时加载的模块数量最多是5个,只分割出同时引入的前5个文件
                     // maxInitialRequests: 30,  //首页加载的时候引入的文件最多3个
-                    automaticNameDelimiter: '-', //缓存组和生成文件名称之间的连接符
+                    automaticNameDelimiter: "-", //缓存组和生成文件名称之间的连接符
                     // name: true,                  //缓存组里面的filename生效,覆盖默认命名
                     cacheGroups: {
                         // vue: {
@@ -53,9 +56,9 @@ module.exports = {
                         //     test: /[\\\/]node_modules[\\\/]/,
                         //     priority: -20
                         // },
-                    }
-                }
-            }
+                    },
+                },
+            };
             // return {
             //     plugins: [
             //         new CompressionPlugin({
@@ -83,25 +86,43 @@ module.exports = {
             //     // new BundleAnalyzerPlugin()
             // ]
         }
-
     },
     parallel: true,
 
     devServer: {
         proxy: {
-            '/': {
+            // 开发环境变化可注释 ⬇️⬇️
+            "/market/CMK": {
+                target: "http://192.168.1.9:9114",
+                ws: false,
+                changeOrigin: true,
+                pathRewrite: {
+                    "^/market": "",
+                },
+            },
+            "/mkWangge": {
+                target: "http://192.168.1.19:9114",
+                ws: false,
+                changeOrigin: true,
+                pathRewrite: {
+                    "^/market": "",
+                },
+            },
+            // 开发环境变化可注释 ⬆️⬆️
+            "/": {
                 // target: 'http://192.168.2.145:9600/spfm',
                 // target: 'http://192.168.2.149:9600',
                 // target: 'http://10.64.42.70:8088/',
                 // target: 'http://114.215.71.182:29600',
-                target: 'http://192.168.1.9:9600/spfm',
+                // target: 'http://192.168.1.9:9600/spfm',
                 // target: 'http://127.0.0.1:9600/',
                 // target: 'http://192.168.0.156:9600/',
                 // target: 'http://192.168.2.170:9600/',
                 // target: 'http://192.168.2.169:9600/',
-                changeOrigin: true
-            }
-        }
+                target: "http://192.168.1.228:9600/spfm",
+                changeOrigin: true,
+            },
+        },
     },
-    transpileDependencies: ['color-string'] // 此段为增加配置选项
-}
+    transpileDependencies: ["color-string"], // 此段为增加配置选项
+};