Files
c-api/capi-ui/vite.config.js
2025-09-02 00:11:55 +08:00

45 lines
1.1 KiB
JavaScript
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

import { defineConfig, loadEnv } from 'vite'
import vue from '@vitejs/plugin-vue'
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'
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({
compiler: 'vue3',
autoInstall: true, // 自动安装图标依赖
}),
],
server: {
proxy: {
[env.VITE_BASE_API]: {
target: env.VITE_SERVER_URL,
changeOrigin: true,
}
}
},
resolve: {
alias: {
'@': resolve(dirname(fileURLToPath(import.meta.url)), 'src')
}
}
})
}