Files
frontend_hmi_station/vite.config.ts

56 lines
1.5 KiB
TypeScript
Raw Permalink Normal View History

2026-01-14 16:35:46 +08:00
import { defineConfig, loadEnv } from 'vite'
import Components from 'unplugin-vue-components/vite' // 按需组件自动导入
import { AntDesignVueResolver } from 'unplugin-vue-components/resolvers'
import vue from '@vitejs/plugin-vue'
import Icons from 'unplugin-icons/vite'
import IconsResolver from 'unplugin-icons/resolver'
import path from 'path'
2025-12-17 17:00:29 +08:00
// https://vite.dev/config/
export default defineConfig(({ mode }) => {
2026-01-14 16:35:46 +08:00
const env = loadEnv(mode, process.cwd())
2025-12-17 17:00:29 +08:00
2026-01-14 16:35:46 +08:00
return {
resolve: {
alias: {
'@': path.resolve(__dirname, 'src'),
},
},
server: {
proxy: {
'/api': {
target: env.VITE_APP_BASE_URL,
changeOrigin: true,
rewrite: (path) => path.replace(/^\/api\//, '/'),
},
'/prod-api': {
target: env.VITE_APP_BASE_URL,
changeOrigin: true,
rewrite: (path) => path.replace(/^\/prod-api\//, '/'),
},
},
},
plugins: [
vue(),
Components({
dts: true, //生成components.d.ts 全局定义文件
resolvers: [
AntDesignVueResolver({
//对使用到的全局ant design vue组件进行类型导入
importStyle: false, // 不动态引入css,这个不强求
}),
// 自动导入 lucide 图标
IconsResolver({
prefix: 'i', // 比如用 <i-a-arrow-down />
enabledCollections: ['lucide'],
}),
],
include: [/\.vue$/, /\.vue\?vue/, /\.md$/, /\.tsx$/], //包含的文件类型
}),
Icons({
autoInstall: true, // 没安装的图标库会自动下载
}),
],
}
})