honojs / vite-plugins

Vite Plugins for Hono
https://hono.dev
130 stars 34 forks source link

SVG not loading during client side hydration #184

Closed AnkurSaini07 closed 1 month ago

AnkurSaini07 commented 1 month ago

I am using hono js, to develop a SSG website https://github.com/AnkurSaini07/vanya-engineering-works

The issue comes only when i run hono/vite-dev-server "bun dev", not on build

While SSR works fine, when I try to hydrate the app on the client side, it fails. I get the following error in the console:

GET http://localhost:5173/src/images/logo.svg?import&react net::ERR_ABORTED 404 (Not Found)

yusukebe commented 1 month ago

Hi @AnkurSaini07

Maybe, this is out of the scope of @hono/vite-dev-server, but about the usage of Vite. If you share a minimal project to reproduce it, I may investigate it.

AnkurSaini07 commented 1 month ago

Hi @yusukebe this is the git repo https://github.com/AnkurSaini07/vanya-engineering-works just run "bun i" and then "bun dev" to run project with vite-devserver open the url: http://localhost:5173/ you will see the error in console "GET http://localhost:5173/src/images/logo.svg?import&react net::ERR_ABORTED 404 (Not Found)"

yusukebe commented 1 month ago

@AnkurSaini07

Thanks! Try this vite.config.ts:

export default defineConfig({
  plugins: [
    // ...
    devServer({
      exclude: [/\/src\/images\/.+/, ...defaultOptions.exclude], // <=== update this line
      adapter: bunAdapter,
      entry: 'src/index.tsx'
    })
  ],
    // ...
})
AnkurSaini07 commented 1 month ago

Thanks, @yusukebe! It works.

yusukebe commented 1 month ago

@AnkurSaini07

Good. Closing this issue.