7b397640b9
问题:Docker 构建时 Vite 无法解析 @/ 路径别名 原因:vite.config.ts 缺少 resolve.alias 配置 解决:添加 @ 别名指向 ./src 目录 Co-Authored-By: Claude Haiku 4.5 <noreply@anthropic.com>
40 lines
1.0 KiB
TypeScript
40 lines
1.0 KiB
TypeScript
import { defineConfig } from "vite";
|
|
import vue from "@vitejs/plugin-vue";
|
|
import { fileURLToPath } from "node:url";
|
|
|
|
export default defineConfig({
|
|
plugins: [
|
|
vue(),
|
|
{
|
|
name: "sanitize-legacy-css",
|
|
generateBundle(_, bundle) {
|
|
for (const asset of Object.values(bundle)) {
|
|
if (asset.type !== "asset" || !asset.fileName.endsWith(".css") || typeof asset.source !== "string") {
|
|
continue;
|
|
}
|
|
asset.source = asset.source
|
|
.replace(/\.el-button::\-moz-focus-inner\{border:0\}/g, "")
|
|
.replace(/\.el-input__inner\[type=password\]::\-ms-reveal\{display:none\}/g, "")
|
|
.replace(/filter:alpha\(opacity=0\);/g, "")
|
|
.replace(/[^{}]*::\-webkit-scrollbar[^{}]*\{[^{}]*\}/g, "");
|
|
}
|
|
},
|
|
},
|
|
],
|
|
resolve: {
|
|
alias: {
|
|
"@": fileURLToPath(new URL("./src", import.meta.url)),
|
|
},
|
|
},
|
|
server: {
|
|
host: true,
|
|
port: 5173,
|
|
proxy: {
|
|
"/api": {
|
|
target: "http://backend:8000",
|
|
changeOrigin: true,
|
|
},
|
|
},
|
|
},
|
|
});
|