Hono Vite DevServer: Wrangler Workers - Proxy is not initialized

I am trying to setup the Hono vite dev server with the wrangler adapter, for some reason theres a race condition with the wrangler proxy. Here is my config:
import { defineConfig, type PluginOption } from 'vite'
import devServer from '@hono/vite-dev-server'
import build from '@hono/vite-build/cloudflare-workers'
import cloudflareAdapter from '@hono/vite-dev-server/cloudflare'
import tsconfigPaths from 'vite-tsconfig-paths'
import tailwindcss from '@tailwindcss/vite'

const entry = './src/index.tsx'
const cloudflareEnvironment = 'development'

export default defineConfig(async ({ command }) => {
return {
assetsInclude: ['**/*.md'],
plugins: [
tailwindcss(),
tsconfigPaths({
root: '.'
}),
...(command === 'serve'
? [
devServer({
entry,
adapter: await cloudflareAdapter({
proxy: { environment: cloudflareEnvironment }
})
})
]
: []),
build({ entry })
] as PluginOption[],
server: {
cors: false
}
}
})
import { defineConfig, type PluginOption } from 'vite'
import devServer from '@hono/vite-dev-server'
import build from '@hono/vite-build/cloudflare-workers'
import cloudflareAdapter from '@hono/vite-dev-server/cloudflare'
import tsconfigPaths from 'vite-tsconfig-paths'
import tailwindcss from '@tailwindcss/vite'

const entry = './src/index.tsx'
const cloudflareEnvironment = 'development'

export default defineConfig(async ({ command }) => {
return {
assetsInclude: ['**/*.md'],
plugins: [
tailwindcss(),
tsconfigPaths({
root: '.'
}),
...(command === 'serve'
? [
devServer({
entry,
adapter: await cloudflareAdapter({
proxy: { environment: cloudflareEnvironment }
})
})
]
: []),
build({ entry })
] as PluginOption[],
server: {
cors: false
}
}
})
And this is an error I sometime get: https://github.com/honojs/vite-plugins/blob/693911738024bb17649a8a418e4dd9dbf6b603af/packages/dev-server/src/adapter/cloudflare.ts#L36
GitHub
vite-plugins/packages/dev-server/src/adapter/cloudflare.ts at 69391...
Vite Plugins for Hono. Contribute to honojs/vite-plugins development by creating an account on GitHub.
0 Replies
No replies yetBe the first to reply to this messageJoin

Did you find this page helpful?