From 7b397640b9987d19195f805e3211227396a0a8e5 Mon Sep 17 00:00:00 2001 From: Cheng Zhou Date: Thu, 14 May 2026 09:31:40 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BF=AE=E5=A4=8D=EF=BC=9A=E6=B7=BB=E5=8A=A0?= =?UTF-8?q?=20Vite=20=E8=B7=AF=E5=BE=84=E5=88=AB=E5=90=8D=E9=85=8D?= =?UTF-8?q?=E7=BD=AE?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 问题:Docker 构建时 Vite 无法解析 @/ 路径别名 原因:vite.config.ts 缺少 resolve.alias 配置 解决:添加 @ 别名指向 ./src 目录 Co-Authored-By: Claude Haiku 4.5 --- frontend/vite.config.ts | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/frontend/vite.config.ts b/frontend/vite.config.ts index 34916c6f..24f9fe69 100644 --- a/frontend/vite.config.ts +++ b/frontend/vite.config.ts @@ -1,5 +1,6 @@ import { defineConfig } from "vite"; import vue from "@vitejs/plugin-vue"; +import { fileURLToPath } from "node:url"; export default defineConfig({ plugins: [ @@ -20,6 +21,11 @@ export default defineConfig({ }, }, ], + resolve: { + alias: { + "@": fileURLToPath(new URL("./src", import.meta.url)), + }, + }, server: { host: true, port: 5173,