Files
c-api/capi-ui/vite.config.js

45 lines
1.1 KiB
JavaScript
Raw Normal View History

2025-09-01 18:18:44 +08:00
import { defineConfig, loadEnv } from 'vite'
2025-08-31 23:25:36 +08:00
import vue from '@vitejs/plugin-vue'
2025-09-01 18:18:44 +08:00
import Icons from 'unplugin-icons/vite' // 图标插件
import IconsResolver from 'unplugin-icons/resolver' // 图标解析器
import Components from 'unplugin-vue-components/vite' // 组件自动导入
import { fileURLToPath, URL } from 'node:url'
import { resolve, dirname } from 'node:path'
2025-08-31 23:25:36 +08:00
2025-09-01 18:18:44 +08:00
export default ({ mode }) => {
const env = loadEnv(mode, process.cwd())
const isProduction = mode === 'production'
return defineConfig({
base: isProduction ? '/cApi/' : '/',
plugins: [
vue(),
Components({
resolvers: [
// 自动解析图标组件前缀为Icon如<IconLogo />
IconsResolver({
prefix: 'Icon',
}),
],
}),
Icons({
2025-09-02 00:11:55 +08:00
compiler: 'vue3',
2025-09-01 18:18:44 +08:00
autoInstall: true, // 自动安装图标依赖
}),
],
server: {
proxy: {
[env.VITE_BASE_API]: {
target: env.VITE_SERVER_URL,
changeOrigin: true,
}
}
},
resolve: {
alias: {
'@': resolve(dirname(fileURLToPath(import.meta.url)), 'src')
}
}
})
}