53 lines
1.2 KiB
JavaScript
53 lines
1.2 KiB
JavaScript
|
|
import { defineConfig } from 'vite'
|
||
|
|
import vue from '@vitejs/plugin-vue'
|
||
|
|
import path from 'path'
|
||
|
|
|
||
|
|
export default defineConfig({
|
||
|
|
plugins: [vue()],
|
||
|
|
resolve: {
|
||
|
|
alias: {
|
||
|
|
'@': path.resolve(__dirname, './src')
|
||
|
|
}
|
||
|
|
},
|
||
|
|
build: {
|
||
|
|
// 启用代码分割
|
||
|
|
rollupOptions: {
|
||
|
|
output: {
|
||
|
|
// 手动分割代码
|
||
|
|
manualChunks: {
|
||
|
|
// 将Element Plus相关代码分割到单独的chunk
|
||
|
|
'element-plus': ['element-plus'],
|
||
|
|
// 将Vue相关代码分割到单独的chunk
|
||
|
|
'vue-vendor': ['vue', 'vue-router', 'pinia'],
|
||
|
|
// 将图表库分割到单独的chunk
|
||
|
|
'charts': ['echarts', 'vue-echarts'],
|
||
|
|
// 将工具库分割到单独的chunk
|
||
|
|
'utils': ['axios', 'dayjs', 'lodash-es']
|
||
|
|
}
|
||
|
|
}
|
||
|
|
},
|
||
|
|
// 启用源码映射
|
||
|
|
sourcemap: false,
|
||
|
|
// 代码压缩
|
||
|
|
minify: 'terser',
|
||
|
|
terserOptions: {
|
||
|
|
compress: {
|
||
|
|
// 移除console
|
||
|
|
drop_console: true,
|
||
|
|
// 移除debugger
|
||
|
|
drop_debugger: true
|
||
|
|
}
|
||
|
|
},
|
||
|
|
// 启用CSS代码分割
|
||
|
|
cssCodeSplit: true
|
||
|
|
},
|
||
|
|
server: {
|
||
|
|
port: 3000,
|
||
|
|
proxy: {
|
||
|
|
'/api': {
|
||
|
|
target: 'http://localhost:5034',
|
||
|
|
changeOrigin: true
|
||
|
|
}
|
||
|
|
}
|
||
|
|
}
|
||
|
|
})
|