Files
mayfly-go/frontend/vite.config.ts
meilin.huang 3768cef62d feat: ai助手优化等
Co-authored-by: Copilot <copilot@github.com>
2026-04-28 22:37:10 +08:00

89 lines
3.0 KiB
TypeScript

import vue from '@vitejs/plugin-vue';
import { resolve } from 'path';
import { CodeInspectorPlugin } from 'code-inspector-plugin';
import progress from 'vite-plugin-progress';
import tailwindcss from '@tailwindcss/vite';
import { ConfigEnv, defineConfig, loadEnv } from 'vite';
export default defineConfig(({ mode }: ConfigEnv) => {
const env = loadEnv(mode, process.cwd(), '');
const isProd = process.env.NODE_ENV === 'production';
const pathResolve = (dir: string): any => {
return resolve(__dirname, '.', dir);
};
return {
base: isProd ? env.VITE_PUBLIC_PATH : './',
resolve: {
alias: {
'@': pathResolve('src/'),
},
},
plugins: [
vue(),
tailwindcss(),
CodeInspectorPlugin({
bundler: 'vite',
editor: env.VITE_EDITOR as any,
}),
progress(),
],
optimizeDeps: {
include: ['element-plus/es/locale/lang/zh-cn'],
},
server: {
host: '0.0.0.0',
port: Number.parseInt(env.VITE_PORT) || 8889,
open: env.VITE_OPEN === 'true',
proxy: {
'/api': {
target: 'http://localhost:18888',
ws: true,
changeOrigin: true,
},
},
},
build: {
outDir: 'dist',
sourcemap: false,
chunkSizeWarningLimit: 1500,
rolldownOptions: {
output: {
entryFileNames: `assets/js/[hash]-[name].js`,
chunkFileNames: `assets/js/[hash]-[name].js`,
assetFileNames: `assets/[ext]/[hash]-[name].[ext]`,
hashCharacters: 'hex',
advancedChunks: {
groups: [
{ name: 'vue-vendor', test: /[\\/]node_modules[\\/](vue|@vue|vue-router|pinia|vue-i18n|@intlify)[\\/]/ },
{ name: 'charts', test: /[\\/]node_modules[\\/](echarts)[\\/]/ },
{ name: 'monaco', test: /[\\/]node_modules[\\/]monaco-editor[\\/]/ },
],
},
},
},
},
define: {
__VUE_I18N_LEGACY_API__: JSON.stringify(false),
__VUE_I18N_FULL_INSTALL__: JSON.stringify(false),
__INTLIFY_PROD_DEVTOOLS__: JSON.stringify(false),
},
css: {
postcss: {
plugins: [
{
postcssPlugin: 'internal:charset-removal',
AtRule: {
charset: (atRule: { name: string; remove: () => void }) => {
if (atRule.name === 'charset') {
atRule.remove();
}
},
},
},
],
},
},
};
});