Skip to content

Vite Plugin: generate sourcemap on build if user specified upload_source_maps: true #11963

@sushichan044

Description

@sushichan044

Describe the solution

Currently, even if upload_source_maps: true is specified in wrangler.json, the Vite Plugin does nothing in particular. To actually upload sourcemaps, you need to write an additional plugin and change the vite config in user land.

I propose handling this internally in the Cloudflare Vite Plugin and automatically generating sourcemaps during the build for all Worker environments.
Specifically, we will set build.sourcemap: true. I believe there are no security issues caused by the code deployed to Workers having sourceMappingURL, and wrangler deploy also sets sourceMappingURL to the end of the worker file.

I am willing to contribute to this change.

Supporting Informations

https://developers.cloudflare.com/workers/wrangler/configuration/#source-maps
https://developers.cloudflare.com/workers/vite-plugin/reference/vite-environments/

https://vite.dev/config/build-options#build-sourcemap
https://vite.dev/guide/api-environment-plugins#registering-new-environments-using-hooks
https://vite.dev/guide/api-environment#environments-configuration:~:text=The%20EnvironmentOptions%20interface%20exposes%20all%20the%20per%2Denvironment%20options.%20There%20are%20environment%20options%20that%20apply%20to%20both%20build%20and%20dev%2C%20like%20resolve.

Metadata

Metadata

Labels

awaiting reporter responseNeeds clarification or followup from OPvite-pluginRelating to the `@cloudflare/vite-plugin` package

Projects

Status

Backlog

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions