Add support for using the Vite plugin without a Wrangler config file#11408
Add support for using the Vite plugin without a Wrangler config file#11408
Conversation
🦋 Changeset detectedLatest commit: be6406d The changes in this PR will be included in the next version bump. 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 |
90c3a70 to
8934055
Compare
create-cloudflare
@cloudflare/kv-asset-handler
miniflare
@cloudflare/pages-shared
@cloudflare/unenv-preset
@cloudflare/vite-plugin
@cloudflare/vitest-pool-workers
@cloudflare/workers-editor-shared
@cloudflare/workers-utils
wrangler
commit: |
eb0c267 to
a064893
Compare
| // Get worker name from package.json name or directory basename | ||
| const packageJsonPath = path.join(root, "package.json"); | ||
| let workerName: string; | ||
| try { | ||
| const packageJsonContent = fs.readFileSync(packageJsonPath, "utf-8"); | ||
| const packageJson = JSON.parse(packageJsonContent) as { name?: string }; | ||
| if (packageJson.name) { | ||
| workerName = unstable_toValidWorkerName(packageJson.name); | ||
| } | ||
| } catch {} | ||
| workerName ??= unstable_toValidWorkerName(path.basename(root)); |
There was a problem hiding this comment.
Should more of this logic be shared with auto-config?
There was a problem hiding this comment.
Reckon I should move it into wrangler?
There was a problem hiding this comment.
OK, moved to wrangler and reused more of the autoconfig code. 593d36c
| ); | ||
| packageJsonName = packageJson.name; | ||
| } catch { | ||
| logger.debug("No package.json found when deriving worker name"); |
There was a problem hiding this comment.
I think we should avoid pulling in the Wrangler logger in these exported utils. If we need debug logs, could we provide the logger as an argument? We could then pass in debuglog from
There was a problem hiding this comment.
OK, I"ll remove it for now. I don't think it's that important.
Add support for using the Vite plugin without a
wrangler.*file. If no file is present it instead generates a default config suitable for an assets-only site.Fixes [DEVX-2351].