2026-02-26 15:22:26 +08:00
|
|
|
import { defineConfig } from 'vite';
|
|
|
|
|
import vue from '@vitejs/plugin-vue';
|
|
|
|
|
import { resolve } from 'path';
|
|
|
|
|
import AutoImport from 'unplugin-auto-import/vite';
|
|
|
|
|
import Components from 'unplugin-vue-components/vite';
|
|
|
|
|
import { AntDesignVueResolver } from 'unplugin-vue-components/resolvers';
|
|
|
|
|
import viteCompression from 'vite-plugin-compression';
|
2026-03-12 13:05:20 +08:00
|
|
|
import fileRouter from 'unplugin-vue-router/vite';
|
2026-02-26 15:22:26 +08:00
|
|
|
|
|
|
|
|
export default defineConfig({
|
|
|
|
|
plugins: [
|
|
|
|
|
vue(),
|
2026-03-12 13:05:20 +08:00
|
|
|
fileRouter({
|
|
|
|
|
routesFolder: 'src/views',
|
|
|
|
|
extensions: ['.vue'],
|
|
|
|
|
importMode: 'sync',
|
|
|
|
|
}),
|
2026-02-26 15:22:26 +08:00
|
|
|
AutoImport({
|
|
|
|
|
imports: [
|
|
|
|
|
'vue',
|
|
|
|
|
'vue-router',
|
|
|
|
|
'pinia',
|
|
|
|
|
{
|
|
|
|
|
'ant-design-vue': ['message', 'notification', 'Modal'],
|
|
|
|
|
},
|
|
|
|
|
],
|
|
|
|
|
dts: 'src/auto-imports.d.ts',
|
2026-03-12 13:05:20 +08:00
|
|
|
// 添加 vue-router 的自动导入
|
|
|
|
|
vueTemplate: true,
|
2026-02-26 15:22:26 +08:00
|
|
|
}),
|
|
|
|
|
Components({
|
|
|
|
|
resolvers: [
|
|
|
|
|
AntDesignVueResolver({
|
|
|
|
|
importStyle: false,
|
|
|
|
|
}),
|
|
|
|
|
],
|
|
|
|
|
dts: 'src/components.d.ts',
|
|
|
|
|
}),
|
|
|
|
|
viteCompression({
|
|
|
|
|
verbose: true,
|
|
|
|
|
disable: false,
|
|
|
|
|
threshold: 10240,
|
|
|
|
|
algorithm: 'gzip',
|
|
|
|
|
ext: '.gz',
|
|
|
|
|
}),
|
|
|
|
|
],
|
|
|
|
|
resolve: {
|
|
|
|
|
alias: {
|
|
|
|
|
'@': resolve(__dirname, 'src'),
|
|
|
|
|
},
|
|
|
|
|
},
|
|
|
|
|
server: {
|
|
|
|
|
port: 5173,
|
|
|
|
|
host: true,
|
|
|
|
|
proxy: {
|
|
|
|
|
'/api': {
|
|
|
|
|
target: 'http://localhost:3000',
|
|
|
|
|
changeOrigin: true,
|
|
|
|
|
rewrite: (path) => path.replace(/^\/api/, '/api'),
|
|
|
|
|
},
|
|
|
|
|
'/uploads': {
|
|
|
|
|
target: 'http://localhost:3000',
|
|
|
|
|
changeOrigin: true,
|
|
|
|
|
},
|
|
|
|
|
},
|
|
|
|
|
},
|
|
|
|
|
build: {
|
|
|
|
|
rollupOptions: {
|
|
|
|
|
output: {
|
|
|
|
|
manualChunks: {
|
|
|
|
|
'ant-design-vue': ['ant-design-vue', '@ant-design/icons-vue'],
|
|
|
|
|
'echarts': ['echarts'],
|
|
|
|
|
'fullcalendar': ['@fullcalendar/vue3', '@fullcalendar/core', '@fullcalendar/daygrid', '@fullcalendar/timegrid', '@fullcalendar/interaction'],
|
|
|
|
|
'dayjs': ['dayjs'],
|
|
|
|
|
},
|
|
|
|
|
},
|
|
|
|
|
},
|
|
|
|
|
chunkSizeWarningLimit: 1000,
|
|
|
|
|
},
|
|
|
|
|
});
|