Files
cz-web/vite.config.ts
2026-10-08 17:26:33 +08:00

40 lines
1.2 KiB
TypeScript
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 { fileURLToPath, URL } from 'node:url'
import vue from '@vitejs/plugin-vue'
import { defineConfig } from 'vite'
// https://vite.dev/config/
export default defineConfig({
plugins: [vue()],
server: {
host: true,
proxy: {
// 开发期把 /api 转发到 vermis-maker 后端(8080),并去掉 /api 前缀
'/api': {
target: 'http://192.168.0.43:8080',
changeOrigin: true,
rewrite: (path) => path.replace(/^\/api/, ''),
},
},
},
resolve: {
alias: {
'@': fileURLToPath(new URL('./src', import.meta.url)),
},
},
css: {
preprocessorOptions: {
less: {
// 自动注入变量与混合宏,组件内可直接使用 @primary-color 等。
// 用绝对路径而非 "@/styles/xxx":Less 会把 "@/..." 当成 less 变量声明,
// 清过 vite 缓存后别名解析失败会导致整条 additionalData 静默失效,
// 表现为所有组件编译报 "Unknown word .flex"。
additionalData: [
`@import "${fileURLToPath(new URL('./src/styles/variables.less', import.meta.url))}";`,
`@import "${fileURLToPath(new URL('./src/styles/mixins.less', import.meta.url))}";`,
].join('\n'),
},
},
},
})