50 lines
1.2 KiB
JavaScript
50 lines
1.2 KiB
JavaScript
|
|
import { defineConfig } from 'vite'
|
||
|
|
import vue from '@vitejs/plugin-vue'
|
||
|
|
import { resolve } from 'path'
|
||
|
|
|
||
|
|
export default defineConfig({
|
||
|
|
base: '/', // 部署到 /admin/ 子路径
|
||
|
|
plugins: [vue()],
|
||
|
|
resolve: {
|
||
|
|
alias: {
|
||
|
|
'@': resolve(__dirname, 'src')
|
||
|
|
}
|
||
|
|
},
|
||
|
|
server: {
|
||
|
|
port: 5173,
|
||
|
|
strictPort: false, // 如果端口被占用,自动尝试下一个
|
||
|
|
open: true,
|
||
|
|
proxy: {
|
||
|
|
'/api': {
|
||
|
|
target: 'http://localhost:8089',
|
||
|
|
changeOrigin: true
|
||
|
|
}
|
||
|
|
}
|
||
|
|
},
|
||
|
|
build: {
|
||
|
|
outDir: 'dist',
|
||
|
|
assetsDir: 'assets',
|
||
|
|
sourcemap: false,
|
||
|
|
chunkSizeWarningLimit: 1500,
|
||
|
|
rollupOptions: {
|
||
|
|
output: {
|
||
|
|
manualChunks(id) {
|
||
|
|
// 将 node_modules 中的包分离
|
||
|
|
if (id.includes('node_modules')) {
|
||
|
|
// element-plus 单独打包
|
||
|
|
if (id.includes('element-plus')) {
|
||
|
|
return 'element-plus'
|
||
|
|
}
|
||
|
|
// vue 相关单独打包
|
||
|
|
if (id.includes('vue') || id.includes('pinia') || id.includes('vue-router')) {
|
||
|
|
return 'vue-vendor'
|
||
|
|
}
|
||
|
|
// 其他第三方库
|
||
|
|
return 'vendor'
|
||
|
|
}
|
||
|
|
}
|
||
|
|
}
|
||
|
|
}
|
||
|
|
}
|
||
|
|
})
|