-
Notifications
You must be signed in to change notification settings - Fork 51
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Local D1 DB persists to wrong directory not picked up by vite #76
Comments
Hi. If you write d1Databases and d1Persist entries in Vite config as the sample repo, the DB schema at startup is made at // vite.config.ts
import pages from '@hono/vite-cloudflare-pages'
import pagesPlugin from '@hono/vite-dev-server/cloudflare-pages'
import honox from 'honox/vite'
import client from 'honox/vite/client'
import { defineConfig } from 'vite'
export default defineConfig(({ mode }) => {
if (mode === 'client') {
return {
plugins: [client()],
}
}
return {
plugins: [
honox({
devServer: {
plugins: [
pagesPlugin({
d1Databases: ['DB'],
d1Persist: true,
}),
],
},
}),
pages(),
],
}
}) Optimizations for these migrate, seed, and uses vary as they depend on the query builder everyone uses, but it would be nice if this specification is clearly stated in the README or in a future Doc. |
I do not think it is unreasonable to expect the |
It works fine you just need to configure HonoX correctly. I am currently using it within a project. You just have to change the directories to match wherever you are pointing wrangler. In my case, I put I agree that more documentation is needed around this. const serversidePlugins = [
tsconfigPaths(),
honox({
devServer: {
cf: {
d1Databases: { TORCH_DATABASE: 'TORCH_DATABASE' },
d1Persist: '../../.wrangler/state/v3/d1',
r2Buckets: ['TORCH_R2'],
r2Persist: '../../.wrangler/state/v3/r2',
kvNamespaces: ['TORCH_AUTH'],
kvPersist: '../../.wrangler/state/v3/kv',
},
},
}),
pages(),
]; |
Thanks for your patience guys! I have managed to get this working with using Key changes: honox({
devServer: {
plugins: [
pagesPlugin({
d1Databases: { DB: "c1ec051a-3e19-4c89-92fa-bdc2b3f69e1c" },
d1Persist: "./.wrangler/state/v3/d1",
}),
],
},
}), |
Hi @KaiSpencer You can use the new API in Wranlger to make it more easy. See here: #39 (comment) |
Thank you so much @yusukebe Works perfectly, much simpler too! |
What version of HonoX are you using?
0.1.3
What steps can reproduce the bug?
Clone the examples repository https://github.com/yusukebe/honox-examples/tree/main/projects/blog
cd to
projects/blog
run
npx wrangler d1 execute hono-blog-demo --local --file=./blog.sql
run
yarn dev
What is the expected behavior?
Local DB is created and when you launch the app it works with seeded db from blog.sql
What do you see instead?
D1_ERROR: no such table: articles
Additional information
the local db is being created in .wrangler, the vite dev plugin is looking in .mf
If you run build and then
wrangler pages dev ./dist
this works, as the wrangler command shims the database in .wrangler and is available to honoxIt seems there needs to be something tweaked with the miniflare setup to pickup local d1 correctly
The text was updated successfully, but these errors were encountered: