honojs / vite-plugins

Vite Plugins for Hono
https://hono.dev
134 stars 35 forks source link

fix(dev-server): add `.mf` to `ignoreWatching` #111

Closed tseijp closed 8 months ago

tseijp commented 8 months ago

The change is minimal, adding .mf to ignoreWatching in vite-plugins/packages/dev-server/src/dev-server.ts.

// dev-server.ts
- ignoreWatching: [/\.wrangler/],
+ ignoreWatching: [/\.wrangler/, /\.mf/],

I've been developing with hono-x and cloudflare d1, but frequently encountered vite errors, causing the server to stop many time.

warn - No utility classes were detected in your source files. If this is unexpected, double-check the `content` option in your Tailwind CSS configuration.
warn - https://tailwindcss.com/docs/content-configuration
/___/node_modules/wrangler/wrangler-dist/cli.js:29573
            throw a;
            ^

Error: The server is being restarted or closed. Request is outdated
    at throwClosedServerError (file:///___/node_modules/vite/dist/node/chunks/dep-jDlpJiMN.js:50329:17)
    at transformRequest (file:///___/node_modules/vite/dist/node/chunks/dep-jDlpJiMN.js:53416:9)
    at Proxy.warmupRequest (file:///___/node_modules/vite/dist/node/chunks/dep-jDlpJiMN.js:64313:19)
    at file:///___/node_modules/vite/dist/node/chunks/dep-jDlpJiMN.js:65812:32
    at async Promise.all (index 0)
    at async TransformContext.transform (file:///___/node_modules/vite/dist/node/chunks/dep-jDlpJiMN.js:65670:13)
    at async Object.transform (file:///___/node_modules/vite/dist/node/chunks/dep-jDlpJiMN.js:50838:30)
    at async loadAndTransform (file:///___/node_modules/vite/dist/node/chunks/dep-jDlpJiMN.js:53611:29)
    at async viteTransformMiddleware (file:///___/node_modules/vite/dist/node/chunks/dep-jDlpJiMN.js:63409:32) {
  code: 'ERR_CLOSED_SERVER'
}

Even without file changes, the vite server kept reloading. Adding .mf to server.watch.ignore resolved the errors, suggesting .mf updates caused clashes.

...
  return {
    server: {
      watch: {
        ignored: [/\.wrangler/, /\.mf/],
      },
...
For reference, I'm using the following `vite.config.ts`. Developing with *react* and *tailwind* on *hono-x* has been very comfortable and enjoyable. Thank you! ```ts import pages from '@hono/vite-cloudflare-pages' import honox from 'honox/vite' import { defineConfig } from 'vite' import { getPlatformProxy } from 'wrangler' export default defineConfig(async ({ mode }) => { if (mode === 'client') { return { build: { rollupOptions: { input: ['./app/client.ts', './app/style.css'], output: { entryFileNames: 'static/client.js', chunkFileNames: 'static/assets/[name]-[hash].js', assetFileNames: 'static/assets/[name].[ext]', }, }, }, } } else { const { env, dispose } = await getPlatformProxy() return { server: { watch: { ignored: [/\.wrangler/, /\.mf/], }, }, ssr: { external: ['react', 'react-dom'], }, plugins: [ honox({ devServer: { env, plugins: [ { onServerClose: dispose, }, ], }, }), pages(), ], } } }) ``` I've been using cloudflare pages for a long time and am truly grateful. Typically using AWS or GCP for the backend, discovering hono led me to cloudflare's d1. Given my limited experience with cloudflare d1, I would appreciate it if you could close my PR if it's off the mark. Thank you!
changeset-bot[bot] commented 8 months ago

🦋 Changeset detected

Latest commit: bfcb35faea591fd1f4c67a3d125704c6b87f90df

The changes in this PR will be included in the next version bump.

This PR includes changesets to release 1 package | Name | Type | | --------------------- | ----- | | @hono/vite-dev-server | Minor |

Not sure what this means? Click here to learn what changesets are.

Click here if you're a maintainer who wants to add another changeset to this PR

yusukebe commented 8 months ago

@tseijp

Thank you! Merge this now.