From a36bec3ade798bdee1aeaf04f5d574a39028187a Mon Sep 17 00:00:00 2001
From: rjg <746338628@qq.com>
Date: Thu, 10 Apr 2025 19:24:59 +0800
Subject: [PATCH] Merge branch 'master' of http://139.196.74.78:10010/r/drone/drone-web-manage
---
vite.config.mjs | 87 ++++++++++++++++++++++++++++++++++++++-----
1 files changed, 76 insertions(+), 11 deletions(-)
diff --git a/vite.config.mjs b/vite.config.mjs
index 0de045a..cb9f299 100644
--- a/vite.config.mjs
+++ b/vite.config.mjs
@@ -1,13 +1,25 @@
-import { defineConfig, loadEnv } from 'vite';
-import { resolve } from 'path';
-import createVitePlugins from './vite/plugins';
+/*
+ * @Author: shuishen 1109946754@qq.com
+ * @Date: 2025-04-10 11:19:47
+ * @LastEditors: shuishen 1109946754@qq.com
+ * @LastEditTime: 2025-04-10 12:23:50
+ * @FilePath: \drone-web-manage\vite.config.mjs
+ * @Description:
+ *
+ * Copyright (c) 2025 by shuishen, All Rights Reserved.
+ */
+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, VITE_APP_URL } = env;
- // 判断是打生产环境包
- const isProd = VITE_APP_ENV === 'production';
+ const env = loadEnv(mode, process.cwd())
+ const { VITE_APP_ENV, VITE_APP_BASE, VITE_APP_URL } = env
+ // 判断是打生产环境包
+ const isProd = VITE_APP_ENV === 'production'
+<<<<<<< HEAD
// 根据是否生产环境,动态设置压缩配置
const buildConfig = {
outDir: 'manage',
@@ -59,8 +71,61 @@
build: buildConfig,
optimizeDeps: {
esbuildOptions: {
+=======
+ // 根据是否生产环境,动态设置压缩配置
+ const buildConfig = {
+ outDir: 'manage',
+>>>>>>> 126bde584b7a925650df0183325cff5094bd8ac3
target: 'esnext',
- },
- },
- });
-};
+ minify: isProd ? 'terser' : 'esbuild', // 根据环境选择压缩工具
+ }
+
+ // 如果是生产环境,添加Terser的配置
+ if (isProd) {
+ buildConfig.terserOptions = {
+ compress: {
+ drop_console: true, // 删除 console
+ drop_debugger: true, // 删除 debugger
+ },
+ format: {
+ comments: false, // 删除所有注释
+ },
+ }
+ }
+ return defineConfig({
+ base: VITE_APP_BASE,
+ define: {
+ __VUE_I18N_FULL_INSTALL__: true,
+ __VUE_I18N_LEGACY_API__: true,
+ __INTLIFY_PROD_DEVTOOLS__: false,
+ },
+ server: {
+ // port: 2888,
+ // host: '192.168.1.178',
+ proxy: {
+ '/api': {
+ // target: 'http://localhost',
+ target: VITE_APP_URL,
+ changeOrigin: true,
+ rewrite: path => path.replace(/^\/api/, ''),
+ },
+ },
+ },
+ resolve: {
+ alias: {
+ '~': resolve(__dirname, './'),
+ '@': resolve(__dirname, './src'),
+ components: resolve(__dirname, './src/components'),
+ styles: resolve(__dirname, './src/styles'),
+ utils: resolve(__dirname, './src/utils'),
+ },
+ },
+ plugins: createVitePlugins(env, command === 'build'),
+ build: buildConfig,
+ optimizeDeps: {
+ esbuildOptions: {
+ target: 'esnext',
+ },
+ },
+ })
+}
--
Gitblit v1.9.3