// SPDX-License-Identifier: LicenseRef-ConusAI-Template-1.0 // The web shell's build: TanStack Start on Vite (F10, docs/reference/app-kit.md). `vite build` writes // `dist/client` (the browser's assets) and `dist/server/server.js` (the Start handler `server.mjs` serves). // // The workspace's own packages resolve to their source, as they do for `tsc` (tsconfig.paths.json), so a // build needs no `build:libs` step first. The kit is left external, Vite's default: a kit package bundled with // `ssr.noExternal` leaves bare imports of its own dependencies behind (`pg`, `@modelcontextprotocol/server`), // which pnpm's strict `node_modules` does not resolve (M5, docs/how-to/use-the-kit-outside-the-template.md ยง3). import { readFileSync } from "node:fs" import { createRequire } from "node:module" import { fileURLToPath } from "node:url" import { tanstackStart } from "@tanstack/react-start/plugin/vite" import react from "@vitejs/plugin-react" import { defineConfig, type Plugin } from "vite" const source = (path: string): string => fileURLToPath(new URL(path, import.meta.url)) /** * The tab icon is the ConusAI mark: the bytes @conusai-kit/brand ships, at `/favicon.png`, the path `appBrand.logo` * names. `dist/client` is what `server.mjs` serves before anything else, signed in or not. An app with a mark of its own * names it in `config/src/brand.ts`. */ function brandFavicon(): Plugin { const file = createRequire(import.meta.url).resolve("@conusai-kit/brand/logo/favicon.png") return { name: "app:brand-favicon", configureServer(server) { server.middlewares.use("/favicon.png", (_request, response) => { response.setHeader("content-type", "image/png") response.end(readFileSync(file)) }) }, generateBundle() { if (this.environment.name === "client") { this.emitFile({ type: "asset", fileName: "favicon.png", source: readFileSync(file) }) } }, } } export default defineConfig({ resolve: { alias: [ { find: /^@app\/config$/, replacement: source("../../config/src/index.ts") }, { find: /^@app\/config\/(.*)$/, replacement: source("../../config/src/$1") }, { find: /^@app\/modules$/, replacement: source("../../modules/index.ts") }, { find: /^@app\/modules\/(.*)$/, replacement: source("../../modules/$1") }, ], }, server: { port: 3510, strictPort: true }, build: { outDir: "dist" }, plugins: [tanstackStart(), react(), brandFavicon()], })