From ecc5079c63e86dd6caba6753b51ed480022bf89b Mon Sep 17 00:00:00 2001 From: zuozhengqing <a13193816592@163.com> Date: 星期一, 05 二月 2024 19:19:01 +0800 Subject: [PATCH] 添加api拦截 --- vue.config.js | 124 +++++++++++++++++++++++------------------ 1 files changed, 70 insertions(+), 54 deletions(-) diff --git a/vue.config.js b/vue.config.js index 8e20141..79620d7 100644 --- a/vue.config.js +++ b/vue.config.js @@ -1,54 +1,70 @@ -const { defineConfig } = require("@vue/cli-service") -module.exports = defineConfig({ - transpileDependencies: true -}) -// const path = require("path") -// const getServerJson = require("./public/serverconfig") -// const devServer = require("./vue.develop.config") -// const { context } = getServerJson -// function resolve(dir) { -// return path.join(__dirname, dir) -// } -// module.exports = { -// publicPath: context, -// lintOnSave: false, -// productionSourceMap: false, // 濡傛灉浣犱笉闇�瑕佺敓浜х幆澧冪殑source map, 鍙互灏嗗叾璁剧疆涓篺alse 浠ュ姞閫熺敓浜х幆澧冩瀯寤� -// devServer, -// transpileDependencies: [ -// // 鍏煎IE11娴忚鍣�(鍏煎npm鍖呭拰cnpm鍖�) -// "crypto-js", -// "sockjs-client" -// ], -// configureWebpack: (config) => { -// if (process.env.NODE_ENV === "production") { -// // 涓虹敓浜х幆澧冧慨鏀归厤缃� -// config.optimization.minimizer[0].options.terserOptions.compress.warings = false -// config.optimization.minimizer[0].options.terserOptions.compress.drop_console = true -// config.optimization.minimizer[0].options.terserOptions.compress.drop_debugger = true -// config.optimization.minimizer[0].options.terserOptions.compress.pure_funcs = ["console.log"] -// config.performance = { -// hints: "warning", -// maxEntrypointSize: 20000000, // 鍏ュ彛璧风偣鐨勬渶澶т綋绉� -// maxAssetSize: 10000000 // 鐢熸垚鏂囦欢鐨勬渶澶т綋绉� -// } -// } else { -// // 涓哄紑鍙戠幆澧冧慨鏀归厤缃� -// config.devtool = "eval-source-map" -// } -// }, -// chainWebpack(config) { -// // 璁剧疆svg瀵煎叆 -// config.module.rule("svg").exclude.add(resolve("srv/assets/icons")).end() -// config.module -// .rule("icons") -// .test(/\.svg$/) -// .include.add(resolve("src/assets/icons")) -// .end() -// .use("svg-sprite-loader") -// .loader("svg-sprite-loader") -// .options({ -// symbolId: "icon-[name]" -// }) -// .end() -// } -// } +const path = require("path") +// 鍩虹璺緞 娉ㄦ剰鍙戝竷涔嬪墠瑕佸厛淇敼杩欓噷 +const publicPath = process.env.VUE_APP_PUBLIC_PATH || "/" +function resolve(dir) { + return path.join(__dirname, dir) +} + +// 璁剧疆涓嶅弬涓庢瀯寤虹殑搴� +const externals = {} +module.exports = { + publicPath, + lintOnSave: false, + productionSourceMap: false, // 濡傛灉浣犱笉闇�瑕佺敓浜х幆澧冪殑source map, 鍙互灏嗗叾璁剧疆涓篺alse 浠ュ姞閫熺敓浜х幆澧冩瀯寤� + devServer: { + proxy: { + "/api/menu":{ + target: "http://192.168.20.119:8001", // http://192.168.20.119:8002 http://fai365.com:30150/ + // 寤洪亾鏈湴鐜 + // target: "http://192.168.20.118:8002", + ws: true, + changeOrigin: true + }, + "/api": { + target: "http://192.168.20.119:8001", // http://192.168.20.119:8002 http://fai365.com:30150/ + // 寤洪亾鏈湴鐜 + // target: "http://192.168.20.118:8002", + ws: true, + changeOrigin: true + } + } + }, + transpileDependencies: [ + // 鍏煎IE11娴忚鍣�(鍏煎npm鍖呭拰cnpm鍖�) + "crypto-js", + "sockjs-client" + ], + configureWebpack: (config) => { + const configNew = {} + if (process.env.NODE_ENV === "production") { + configNew.externals = externals + configNew.plugins = [] + } else if (process.env.NODE_ENV === "development") { + console.log("development", config) + } + return configNew + }, + chainWebpack(config) { + // 璁剧疆svg瀵煎叆 + config.module.rule("svg").exclude.add(resolve("srv/assets/icons")).end() + config.module + .rule("icons") + .test(/\.svg$/) + .include.add(resolve("src/assets/icons")) + .end() + .use("svg-sprite-loader") + .loader("svg-sprite-loader") + .options({ + symbolId: "icon-[name]" + }) + .end() + }, + css: { + loaderOptions: { + // 璁剧疆 scss 鍏敤鍙橀噺鏂囦欢 + sass: { + additionalData: `@import "@/assets/style/variable.scss";` + } + } + } +} -- Gitblit v1.8.0