From 88622f506d1de11347c02e643cba1ff9199769cd Mon Sep 17 00:00:00 2001 From: yangzongjia Date: Sat, 10 Jun 2023 19:39:16 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BF=AE=E6=94=B9=E9=85=8D=E7=BD=AE?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .env.production | 3 ++- vue.config.js | 49 +++++++++++++++++++++++++------------------------ 2 files changed, 27 insertions(+), 25 deletions(-) diff --git a/.env.production b/.env.production index eef7d99..b41d2e0 100644 --- a/.env.production +++ b/.env.production @@ -2,7 +2,8 @@ ENV = 'production' # base api -VUE_APP_BASE_API = '/monitorapi' +# VUE_APP_BASE_API = '/monitorapi' +VUE_APP_BASE_API = '/api' ## 配置 正式接口地址 VUE_APP_URL = "http://120.46.131.15:8111" diff --git a/vue.config.js b/vue.config.js index 35f96af..1e5979f 100644 --- a/vue.config.js +++ b/vue.config.js @@ -24,7 +24,8 @@ module.exports = { *在大多数情况下,请使用“/”!!! *详细信息:https://cli.vuejs.org/config/#publicpath */ - publicPath: process.env.NODE_ENV === 'production' ? '/monitor/' : '/', + // publicPath: process.env.NODE_ENV === 'production' ? '/monitor/' : '/', + publicPath: process.env.NODE_ENV === 'production' ? '/' : '/', outputDir: 'monitor-ui', assetsDir: 'static', lintOnSave: process.env.NODE_ENV === 'development', @@ -41,7 +42,7 @@ module.exports = { proxy: { '/api': { // 匹配所有以 '/api'开头的请求路径 // target: 'http://192.168.1.109:8111', - target: process.env.VUE_APP_URL, // 代理目标的基础路径 + target: process.env.VUE_APP_URL, // 代理目标的基础路径 changeOrigin: true, // 支持跨域 pathRewrite: { // 重写路径: 去掉路径中开头的'/api' '^/api': '' @@ -49,7 +50,7 @@ module.exports = { }, '/upload': { // 匹配所有以 '/api'开头的请求路径 // target: 'http://120.46.131.15:8111', - target: process.env.VUE_APP_URL, // 代理目标的基础路径 + target: process.env.VUE_APP_URL, // 代理目标的基础路径 changeOrigin: true, // 支持跨域 pathRewrite: { // 重写路径: 去掉路径中开头的'/api' '^/upload': '' @@ -112,28 +113,28 @@ module.exports = { .end() config .optimization.splitChunks({ - chunks: 'all', - cacheGroups: { - libs: { - name: 'chunk-libs', - test: /[\\/]node_modules[\\/]/, - priority: 10, - chunks: 'initial' // only package third parties that are initially dependent - }, - elementUI: { - name: 'chunk-elementUI', // split elementUI into a single package - priority: 20, // the weight needs to be larger than libs and app or it will be packaged into libs or app - test: /[\\/]node_modules[\\/]_?element-ui(.*)/ // in order to adapt to cnpm - }, - commons: { - name: 'chunk-commons', - test: resolve('src/components'), // can customize your rules - minChunks: 3, // minimum common number - priority: 5, - reuseExistingChunk: true + chunks: 'all', + cacheGroups: { + libs: { + name: 'chunk-libs', + test: /[\\/]node_modules[\\/]/, + priority: 10, + chunks: 'initial' // only package third parties that are initially dependent + }, + elementUI: { + name: 'chunk-elementUI', // split elementUI into a single package + priority: 20, // the weight needs to be larger than libs and app or it will be packaged into libs or app + test: /[\\/]node_modules[\\/]_?element-ui(.*)/ // in order to adapt to cnpm + }, + commons: { + name: 'chunk-commons', + test: resolve('src/components'), // can customize your rules + minChunks: 3, // minimum common number + priority: 5, + reuseExistingChunk: true + } } - } - }) + }) // https:// webpack.js.org/configuration/optimization/#optimizationruntimechunk config.optimization.runtimeChunk('single') }