Fork Horse repository, listed by its owner. Publisher snapshot.

packages/forkhorse-dashboard/vite.config.ts

Snapshot at 34e3175

Containing directory

1,503 bytes · typescriptView raw
1import tailwindcss from "@tailwindcss/vite";
2import { readFileSync } from "node:fs";
3import { defineConfig, type ViteDevServer } from "vite-plus";
4import { fixtureMiddleware } from "./test/fixture-api.ts";
5import { markIconUrl } from "./src/mark.ts";
6
7const brand = JSON.parse(readFileSync(new URL("../../brand.json", import.meta.url), "utf8"));
8export default defineConfig(({ mode }) => ({
9  base: mode === "fixture" ? "/" : "/app/",
10  define: { __DASHBOARD_BRAND__: JSON.stringify({ name: brand.name, tagline: brand.tagline }) },
11  build: {
12    outDir: mode === "fixture" ? "dist-fixture" : "dist",
13    rollupOptions: {
14      onwarn(warning, warn) {
15        // Kumo is client-only here; Rollup may safely remove its React server directive.
16        if (warning.code === "MODULE_LEVEL_DIRECTIVE" && warning.message.includes("use client"))
17          return;
18        warn(warning);
19      },
20      input: mode === "fixture" ? "fixtures.html" : "index.html",
21    },
22  },
23  esbuild: { jsx: "automatic" },
24  plugins: [
25    {
26      name: "brand-favicon",
27      transformIndexHtml() {
28        return [{ tag: "link", attrs: { rel: "icon", type: "image/svg+xml", href: markIconUrl(brand.mark) }, injectTo: "head" }];
29      },
30    },
31    tailwindcss(),
32    ...(mode === "fixture"
33      ? [
34          {
35            name: "local-fixture-api",
36            configureServer(server: ViteDevServer) {
37              server.middlewares.use(fixtureMiddleware());
38            },
39          },
40        ]
41      : []),
42  ],
43}));
44