this repo has no description
1import { defineConfig } from "vite";
2import { fresh } from "@fresh/plugin-vite";
3
4export default defineConfig({
5 plugins: [
6 fresh(),
7 {
8 name: "atmosphere-fresh-island-dev-imports",
9 apply: "serve",
10 enforce: "post",
11 transformIndexHtml(html) {
12 /**
13 * Fresh's dev SSR currently emits inline module imports like
14 * `from "fresh-island::AccountMenu.tsx"`. The Vite dev server can
15 * serve those modules at `/@id/fresh-island::...`, but browsers try
16 * to resolve the bare `fresh-island::` scheme directly and block it.
17 * This keeps local island hydration working without affecting builds.
18 */
19 return html.replaceAll(
20 /from "fresh-island::([^"]+)"/g,
21 'from "/@id/fresh-island::$1"',
22 );
23 },
24 },
25 ],
26 server: {
27 /** Match local OAuth / site URL defaults; fail fast if another dev server is still bound. */
28 port: 5173,
29 strictPort: true,
30 /** Disable browser caching during dev so every save is reflected on the next request
31 * without needing a hard refresh. Vite HMR still applies in-place for CSS and islands. */
32 headers: {
33 "Cache-Control": "no-store, no-cache, must-revalidate, max-age=0",
34 "Pragma": "no-cache",
35 "Expires": "0",
36 },
37 /** Make sure HMR uses the same port so client/server stay in sync. */
38 hmr: { port: 5173 },
39 /** Reload the page when files outside the JS module graph change (e.g. assets/*.css
40 * imports, server route files). */
41 watch: { usePolling: false },
42 },
43});