From a651afeb0597ae6c6591d7116e9bf80a88cb2901 Mon Sep 17 00:00:00 2001 From: toesbieya <1647775459@qq.com> Date: Thu, 4 Feb 2021 14:58:36 +0800 Subject: [PATCH] =?UTF-8?q?=E7=9B=B4=E6=8E=A5=E4=BD=BF=E7=94=A8process.env?= =?UTF-8?q?.NODE=5FENV?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- vue/full/src/config/index.js | 11 ++++------- vue/full/vue.config.js | 5 +++-- 2 files changed, 7 insertions(+), 9 deletions(-) diff --git a/vue/full/src/config/index.js b/vue/full/src/config/index.js index 261acfe..86178c5 100644 --- a/vue/full/src/config/index.js +++ b/vue/full/src/config/index.js @@ -1,9 +1,6 @@ -const isDev = process.env.NODE_ENV === 'development' -const contextPath = isDev ? '/' : '/jxc-admin/' +const contextPath = process.env.NODE_ENV === 'development' ? '/' : '/jxc-admin/' module.exports = { - isDev, - //项目的部署路径,始终以'/'开头,以'/'结束 contextPath, @@ -20,7 +17,7 @@ module.exports = { useMock: false, //socket连接地址 - socketUrl: isDev ? 'http://localhost:12580' : 'https://toesbieya.cn', + socketUrl: process.env.NODE_ENV === 'development' ? 'http://localhost:12580' : 'https://toesbieya.cn', //路由配置 route: { @@ -40,7 +37,7 @@ module.exports = { storePrefix: 'https://static.toesbieya.cn/', //预览地址前缀 - previewPrefix: isDev ? 'http://localhost:8012' : 'https://preview.toesbieya.cn', + previewPrefix: process.env.NODE_ENV === 'development' ? 'http://localhost:8012' : 'https://preview.toesbieya.cn', }, //本地存储配置 @@ -49,6 +46,6 @@ module.exports = { keyPrefix: 'GCC-', //读写时是否进行压缩的默认值 - zip: !isDev + zip: process.env.NODE_ENV !== 'development' } } diff --git a/vue/full/vue.config.js b/vue/full/vue.config.js index 150d2cb..611e8a9 100644 --- a/vue/full/vue.config.js +++ b/vue/full/vue.config.js @@ -1,6 +1,7 @@ const path = require('path') const settings = require('./src/config') const CompressionWebpackPlugin = require('compression-webpack-plugin') +const isDev = process.env.NODE_ENV === 'development' function resolve(dir) { return path.join(__dirname, dir) @@ -12,7 +13,7 @@ module.exports = { assetsDir: 'static', runtimeCompiler: true, lintOnSave: false, - productionSourceMap: settings.isDev, + productionSourceMap: isDev, transpileDependencies: ['el-admin-layout'], devServer: { port: process.env.port || 8079, @@ -70,7 +71,7 @@ module.exports = { .options({symbolId: 'icon-[name]'}) .end() - config.when(!settings.isDev, config => { + config.when(!isDev, config => { //将css合并到一个文件中 //https://github.com/vuejs/vue-cli/issues/2843 config