Skip to content

Commit d7400e9

Browse files
committed
chore: inject Vite client script manually
1 parent 0ee8660 commit d7400e9

File tree

2 files changed

+16
-1
lines changed

2 files changed

+16
-1
lines changed

website/src/components/templates/BaseTemplate.tsx

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
import { Style, css } from "hono/css";
2+
import { html } from "hono/html";
23
import type { FC, PropsWithChildren } from "hono/jsx";
34
import { basePath } from "../../metadata";
45
import type { Page } from "../../types/model";
@@ -174,6 +175,13 @@ samp {
174175
"Liberation Mono", "Courier New", monospace;
175176
}
176177
`}</Style>
178+
{/* NOTE: @hono/vite-dev-server does not respect the base setting in the Vite configuration. */}
179+
{import.meta.env.DEV &&
180+
html`
181+
<script>
182+
import("${basePath.replace(/\/$/, "")}/@vite/client")
183+
</script>
184+
`}
177185
</head>
178186

179187
<body

website/vite.config.ts

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,14 @@ export default defineConfig({
3838
}),
3939
devServer({
4040
entry: "src/index.tsx",
41-
exclude: [...defaultOptions.exclude, /^\/assets\/.+/, /^\/index\.html$/],
41+
exclude: [
42+
...defaultOptions.exclude,
43+
/^\/assets\/.+/,
44+
/^\/index\.html$/,
45+
// NOTE: @hono/vite-dev-server does not respect the base setting in the Vite configuration.
46+
new RegExp(`^${basePath.replace(/\/$/, "")}/@.+`),
47+
new RegExp(`^${basePath.replace(/\/$/, "")}/node_modules(?:/|$)`),
48+
],
4249
}),
4350
],
4451
build: {

0 commit comments

Comments
 (0)