Vite on Workers

When I integrate Vite to Workers through stable CF Vite plugin should I change dev commands to vite dev or still stick with wrangler dev. I don't have access to bindings when starting with vite command.
No description
1 Reply
twiceburnt
twiceburnt2w ago
you may need to add a tsconfig.worker.json file
{
"compilerOptions": {
"tsBuildInfoFile": "./node_modules/.tmp/tsconfig.worker.tsbuildinfo",
"types": ["./worker-configuration.d.ts", "vite/client"]
},
"include": ["server"]
}
{
"compilerOptions": {
"tsBuildInfoFile": "./node_modules/.tmp/tsconfig.worker.tsbuildinfo",
"types": ["./worker-configuration.d.ts", "vite/client"]
},
"include": ["server"]
}
and reference it in the tsconfig.json file
{
"files": [],
"references": [
{
"path": "./tsconfig.app.json"
},
{
"path": "./tsconfig.node.json"
},
{
"path": "./tsconfig.worker.json"
}
],
"compilerOptions": {
"baseUrl": ".",
"paths": {
"@/*": ["./src/*"]
}
}
}
{
"files": [],
"references": [
{
"path": "./tsconfig.app.json"
},
{
"path": "./tsconfig.node.json"
},
{
"path": "./tsconfig.worker.json"
}
],
"compilerOptions": {
"baseUrl": ".",
"paths": {
"@/*": ["./src/*"]
}
}
}
then generate the worker-configuration.d.ts with wrangler types

Did you find this page helpful?