@cloudflare/vite-plugin 0.0.0-b7d6b7dd1 → 0.0.0-b8fd1b1c8
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +1 -61
- package/dist/asset-workers/asset-worker.js +420 -456
- package/dist/index.d.ts +1 -2
- package/dist/index.js +6997 -7162
- package/dist/runner-worker/index.js +22 -55
- package/package.json +10 -11
package/README.md
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
# `@cloudflare/vite-plugin`
|
|
2
2
|
|
|
3
|
-
[Intro](#intro) | [Quick start](#quick-start) | [Tutorial](#tutorial) | [API](#api) | [Cloudflare environments](#cloudflare-environments) | [
|
|
3
|
+
[Intro](#intro) | [Quick start](#quick-start) | [Tutorial](#tutorial) | [API](#api) | [Cloudflare environments](#cloudflare-environments) | [Migrating from `wrangler dev`](#migrating-from-wrangler-dev)
|
|
4
4
|
|
|
5
5
|
## Intro
|
|
6
6
|
|
|
@@ -374,10 +374,6 @@ It accepts an optional `PluginConfig` parameter.
|
|
|
374
374
|
All requests are routed through your entry Worker.
|
|
375
375
|
During the build, each Worker is output to a separate subdirectory of `dist`.
|
|
376
376
|
|
|
377
|
-
- `inspectorPort?: number | false`
|
|
378
|
-
|
|
379
|
-
Optional inspector port to use for debugging your workers, for more details on debugging see the [devtools section](#devtools). Can be set to `false` to disable the debugging inspector altogether. Defaults to `9229`.
|
|
380
|
-
|
|
381
377
|
> [!NOTE]
|
|
382
378
|
> When running `wrangler deploy`, only your main (entry) Worker will be deployed.
|
|
383
379
|
> If using multiple Workers, each must be deployed individually.
|
|
@@ -486,62 +482,6 @@ Secrets can be provided to your Worker in local development using a [`.dev.vars`
|
|
|
486
482
|
> [!NOTE]
|
|
487
483
|
> The `vite build` command copies the relevant `.dev.vars[.env-name]` file to the output directory. This is only used when running `vite preview` and is not deployed with your Worker.
|
|
488
484
|
|
|
489
|
-
## Debugging
|
|
490
|
-
|
|
491
|
-
The Cloudflare Vite plugin allows you to conveniently debug your Worker code during local development.
|
|
492
|
-
|
|
493
|
-
By default the inspector port used by the plugin is `9229`, which can be customized by providing a different port to the plugin's `inspectorPort` option.
|
|
494
|
-
|
|
495
|
-
There are two recommended ways of doing so, which we'll explore in this section.
|
|
496
|
-
|
|
497
|
-
### Devtools
|
|
498
|
-
|
|
499
|
-
When running `vite dev` or `vite preview` a `/__debug` route in your local server will be made available which gives you access to [Cloudflare's implementation](/packages/chrome-devtools-patches) of [Chrome's DevTools](https://developer.chrome.com/docs/devtools/overview).
|
|
500
|
-
|
|
501
|
-
Navigating to this route will open a devtools tab for each of the workers in your application (Note: in case of multiple workers you might need to allow your browser to open pop-ups).
|
|
502
|
-
|
|
503
|
-
Once the tab or tabs are open, you can make a request to your application and start debugging your workers' code.
|
|
504
|
-
|
|
505
|
-
Note: If you're not interested in debugging all your workers you can close the tabs of the workers you don't want to debug.
|
|
506
|
-
|
|
507
|
-
### VS Code
|
|
508
|
-
|
|
509
|
-
To setup VS Code for breakpoint debugging for your application, you will need to create a `.vscode/launch.json` file that contains a configuration following this structure:
|
|
510
|
-
|
|
511
|
-
```json
|
|
512
|
-
{
|
|
513
|
-
"configurations": [
|
|
514
|
-
{
|
|
515
|
-
"name": "<NAME_OF_WORKER>",
|
|
516
|
-
"type": "node",
|
|
517
|
-
"request": "attach",
|
|
518
|
-
"websocketAddress": "ws://localhost:9229/<NAME_OF_WORKER>",
|
|
519
|
-
"resolveSourceMapLocations": null,
|
|
520
|
-
"attachExistingChildren": false,
|
|
521
|
-
"autoAttachChildProcesses": false,
|
|
522
|
-
"sourceMaps": true
|
|
523
|
-
}
|
|
524
|
-
],
|
|
525
|
-
"compounds": [
|
|
526
|
-
{
|
|
527
|
-
"name": "Debug All Workers",
|
|
528
|
-
"configurations": ["<NAME_OF_WORKER>"],
|
|
529
|
-
"stopAll": true
|
|
530
|
-
}
|
|
531
|
-
]
|
|
532
|
-
}
|
|
533
|
-
```
|
|
534
|
-
|
|
535
|
-
Where, `<NAME_OF_WORKER>` indicates the name of your worker as specified in your Wrangler configuration.
|
|
536
|
-
|
|
537
|
-
Note: if you customized your `inspectorPort` you need to use that port in the `websocketAddress` field.
|
|
538
|
-
|
|
539
|
-
If you have more than one worker you need add a configuration in the `configurations` field for each one and then include the configuration name in the `configurations` array in the compound configuration.
|
|
540
|
-
|
|
541
|
-
Once your `launch.json` file is ready, after running `vite dev` or `vite preview` you can select **Debug All Workers** at the top of the **Run & Debug** panel to attach debuggers to all the various Workers. Then you can add breakpoints to your code and start debugging.
|
|
542
|
-
|
|
543
|
-
Note: You can also manually select the configurations to run (e.g. **Debug Worker1**) to filter which workers you want to debug.
|
|
544
|
-
|
|
545
485
|
## Migrating from `wrangler dev`
|
|
546
486
|
|
|
547
487
|
Migrating from `wrangler dev` is a simple process and you can follow the instructions in the [Quick start](#quick-start) to get started.
|