|
|
import { defineConfig } from 'vite'
|
|
|
import vue from '@vitejs/plugin-vue'
|
|
|
import { resolve } from 'path'
|
|
|
import { createSvgIconsPlugin } from 'vite-plugin-svg-icons'
|
|
|
|
|
|
export default defineConfig(async () => ({
|
|
|
plugins: [
|
|
|
vue(),
|
|
|
createSvgIconsPlugin({
|
|
|
// 指定 SVG 文件目录(递归扫描)
|
|
|
iconDirs: [resolve(__dirname, 'src/assets/image')],
|
|
|
// symbol id 格式:icon-文件夹-文件名
|
|
|
symbolId: 'icon-[dir]-[name]',
|
|
|
// 注入位置
|
|
|
inject: 'body-last',
|
|
|
customDomId: '__svg_sprite__',
|
|
|
}),
|
|
|
],
|
|
|
base: "./",
|
|
|
server: {
|
|
|
port: '55813', // 指定启动端口
|
|
|
open: true, //启动后是否自动打开浏览器
|
|
|
proxy: {
|
|
|
'/api': {
|
|
|
// target: 'https://kcsl-dev.kangcer.com',
|
|
|
// target: 'http://localhost:53801',
|
|
|
// target: 'http://localhost:10640',
|
|
|
target: 'http://localhost:5276',
|
|
|
secure: false,
|
|
|
changeOrigin: true,
|
|
|
rewrite: path => path.replace(/^\/api/, '')
|
|
|
}
|
|
|
}
|
|
|
},
|
|
|
resolve: {
|
|
|
// 配置别名 添加的,这里只添加了一个别名,想配置更多别名就在这里再加条目即可
|
|
|
alias: {
|
|
|
'@': resolve(__dirname, './src'),
|
|
|
}
|
|
|
},
|
|
|
css: {
|
|
|
preprocessorOptions: {
|
|
|
scss: {
|
|
|
// 使用纯 JS 版本的 sass,避免 sass-embedded 在 Windows 上处理大量 SCSS 时内存爆炸
|
|
|
implementation: await import('sass'),
|
|
|
silenceDeprecations: ['legacy-js-api', 'import', 'global-builtin', 'color-functions'],
|
|
|
},
|
|
|
},
|
|
|
},
|
|
|
build: {
|
|
|
// 提高 sourcemap 阈值以减少内存峰值
|
|
|
sourcemap: false,
|
|
|
// 警告阈值:项目中含 element-plus 全量样式 + echarts,体积较大,放宽到 2MB
|
|
|
chunkSizeWarningLimit: 2000,
|
|
|
rollupOptions: {
|
|
|
output: {
|
|
|
// 把大型依赖拆成独立 chunk,减少单 chunk 体积并改善首屏
|
|
|
manualChunks: {
|
|
|
'vue-vendor': ['vue', 'vue-router', 'pinia', 'pinia-plugin-persistedstate'],
|
|
|
'element-plus': ['element-plus', '@element-plus/icons-vue'],
|
|
|
'echarts-vendor': ['echarts', 'vue-echarts'],
|
|
|
'editor-vendor': ['@wangeditor/editor', '@wangeditor/editor-for-vue'],
|
|
|
'pdf-vendor': ['vue-pdf-embed'],
|
|
|
},
|
|
|
},
|
|
|
},
|
|
|
},
|
|
|
}))
|