Files
coconut-leaf/frontend/vite.config.ts
T

51 lines
1.6 KiB
TypeScript
Raw Normal View History

2026-04-28 15:47:32 +08:00
import { fileURLToPath, URL } from 'node:url'
import { defineConfig } from 'vite'
import vue from '@vitejs/plugin-vue'
import vueDevTools from 'vite-plugin-vue-devtools'
// https://vite.dev/config/
export default defineConfig({
plugins: [
vue(),
vueDevTools(),
],
resolve: {
alias: {
'@': fileURLToPath(new URL('./src', import.meta.url))
},
},
2026-07-19 16:25:46 +08:00
css: {
preprocessorOptions: {
scss: {
// 静默来自 Bulma 0.9.1 的 Sass 弃用警告(import / global-builtin / color-functions / slash-div / if-function
// Bulma 0.9.1(发布于 2021 年)与新版 Dart Sass 不兼容。
// 我的 pnpm-lock.yaml 和 node_modules 中的 Dart Sass 是 Vite 8 自带的新版本,而 Bulma 0.9.1 使用了大量已被 deprecate 的 Sass 老语法。
// 我不想做任何升级,因此强制压制这些错误,还编译日志一个干净。
silenceDeprecations: ['import', 'global-builtin', 'color-functions', 'slash-div', 'if-function'],
},
},
},
// 项目基础路径(对应 Nginx 路由到的 /web 前缀)
base: '/web/',
server: {
port: 5173, // 开发服务器默认端口
open: '/web/', // 启动时自动打开 /web 路径
// 核心:代理配置(对应 Nginx 的 /api -> Go 服务)
proxy: {
// 精细控制路由,对齐生产环境
'^/api/(.*)$': {
target: 'http://127.0.0.1:8848',
changeOrigin: true,
// 路径重写/api/user -> /user
rewrite: (path) => path.replace(/^\/api\//, '/'),
}
},
},
2026-04-28 15:47:32 +08:00
})