import { fileURLToPath, URL } from "node:url"; import { defineConfig } from "vite"; import react from "@vitejs/plugin-react"; import { TanStackRouterVite } from "@tanstack/router-plugin/vite"; export default defineConfig({ plugins: [ TanStackRouterVite({ target: "react", autoCodeSplitting: true }), react(), ], resolve: { // 聚珍(cjk-autospace submodule)以包名 import;运行时指向 ESM bundle, // 类型由 tsconfig paths 指向 dist/index.d.ts。CSS 走 index.css 相对 @import。 alias: { "cjk-autospace": fileURLToPath( new URL("./src/lib/cjk-autospace/dist/juzhen.mjs", import.meta.url), ), }, }, build: { // 多入口:main = 完整 React 应用(index.html);engine = iOS 无头传输引擎 // (engine.html,不含 React / UI,见 src/engine/main.ts、ios/PLAN.md arch A)。 // 两个 bundle 互不污染——engine 不把 React / 路由拖进 main,main 也不含引擎入口。 rollupOptions: { input: { main: fileURLToPath(new URL("./index.html", import.meta.url)), engine: fileURLToPath(new URL("./engine.html", import.meta.url)), }, }, }, server: { proxy: { "/api": "http://localhost:8080", }, }, });