dedsudiyu 1 semana atrás
pai
commit
8e65b88f43
4 arquivos alterados com 77 adições e 1 exclusões
  1. 11 0
      .env.development
  2. 11 0
      .env.production
  3. BIN
      public/favicon.ico
  4. 55 1
      vue.config.js

+ 11 - 0
.env.development

@@ -0,0 +1,11 @@
+# 开发环境配置
+NODE_ENV=development
+
+# 项目名称
+VUE_APP_TITLE=中国安全生产科学研究院实验室安全智慧化管控中心
+
+# 接口基础地址
+VUE_APP_BASE_API=http://localhost:9090/api
+
+# 接口超时时间(毫秒)
+VUE_APP_TIMEOUT=10000

+ 11 - 0
.env.production

@@ -0,0 +1,11 @@
+# 生产环境配置
+NODE_ENV=production
+
+# 项目名称
+VUE_APP_TITLE=中国安全生产科学研究院实验室安全智慧化管控中心
+
+# 接口基础地址
+VUE_APP_BASE_API=https://lab-screen.example.com/api
+
+# 接口超时时间(毫秒)
+VUE_APP_TIMEOUT=15000

BIN
public/favicon.ico


+ 55 - 1
vue.config.js

@@ -1,16 +1,70 @@
 const { defineConfig } = require('@vue/cli-service')
+
 module.exports = defineConfig({
   transpileDependencies: true,
   lintOnSave: false,
+  productionSourceMap: false,
+
   devServer: {
     port: 8080,
-    open: true
+    open: true,
+    proxy: {
+      '/api': {
+        target: process.env.VUE_APP_BASE_API,
+        changeOrigin: true,
+        pathRewrite: { '^/api': '' }
+      }
+    }
   },
+
   css: {
     loaderOptions: {
       sass: {
         additionalData: `@import "@/styles/variables.scss";`
       }
     }
+  },
+
+  chainWebpack(config) {
+    // 页面标题
+    config.plugin('html').tap(args => {
+      args[0].title = process.env.VUE_APP_TITLE || '实验室安全智慧化管控中心'
+      return args
+    })
+  },
+
+  configureWebpack: {
+    optimization: {
+      splitChunks: {
+        chunks: 'all',
+        cacheGroups: {
+          // Vue 全家桶
+          vue: {
+            name: 'chunk-vue',
+            test: /[\\/]node_modules[\\/](vue|vue-router|vuex)[\\/]/,
+            priority: 30
+          },
+          // ECharts 单独拆包(体积最大)
+          echarts: {
+            name: 'chunk-echarts',
+            test: /[\\/]node_modules[\\/](echarts|zrender)[\\/]/,
+            priority: 25
+          },
+          // Element UI
+          elementUI: {
+            name: 'chunk-element-ui',
+            test: /[\\/]node_modules[\\/]element-ui[\\/]/,
+            priority: 20
+          },
+          // 其余第三方
+          vendors: {
+            name: 'chunk-vendors',
+            test: /[\\/]node_modules[\\/]/,
+            priority: 10,
+            reuseExistingChunk: true
+          }
+        }
+      }
+    }
   }
 })