无人机管理后台前端(已迁走)
shuishen
2025-05-19 2dfc8dc4bcd3d3cd4aed1b6054e073e140eba9c8
vite.config.mjs
@@ -1,24 +1,16 @@
import {
  defineConfig,
  loadEnv
} from 'vite';
import { resolve } from 'path'
import { defineConfig, loadEnv } from 'vite';
import { resolve } from 'path';
import createVitePlugins from './vite/plugins';
// https://vitejs.dev/config/
export default ({
  mode,
  command
}) => {
  const env = loadEnv(mode, process.cwd())
  const {
    VITE_APP_ENV,
    VITE_APP_BASE
  } = env
export default ({ mode, command }) => {
  const env = loadEnv(mode, process.cwd());
  const { VITE_APP_ENV, VITE_APP_BASE, VITE_APP_URL } = env;
  // 判断是打生产环境包
  const isProd = VITE_APP_ENV === 'production'
  const isProd = VITE_APP_ENV === 'production';
  // 根据是否生产环境,动态设置压缩配置
  const buildConfig = {
    outDir: 'manage',
    target: 'esnext',
    minify: isProd ? 'terser' : 'esbuild', // 根据环境选择压缩工具
  };
@@ -31,8 +23,8 @@
        drop_debugger: true, // 删除 debugger
      },
      format: {
        comments: false // 删除所有注释
      }
        comments: false, // 删除所有注释
      },
    };
  }
  return defineConfig({
@@ -40,14 +32,15 @@
    define: {
      __VUE_I18N_FULL_INSTALL__: true,
      __VUE_I18N_LEGACY_API__: true,
      __INTLIFY_PROD_DEVTOOLS__: false
      __INTLIFY_PROD_DEVTOOLS__: false,
    },
    server: {
      port: 2888,
      // port: 2888,
      // host: '192.168.1.178',
      proxy: {
        '/api': {
          target: 'http://localhost',
          //target: 'https://saber3.bladex.cn/api',
           //target: 'http://localhost',
          target: VITE_APP_URL,
          changeOrigin: true,
          rewrite: path => path.replace(/^\/api/, ''),
        },