Repository navigation
Private source maps with Vite: hidden maps, upload, then remove from dist #23926
virajrakholiya
started this conversation in
Show and tell
Replies: 0 comments
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
Sharing a pattern for readable production stack traces from a Vite app without publishing your source.
build.sourcemap: "hidden". Vite writes the.mapfiles but leaves out the//# sourceMappingURLcomment, so browsers never ask for them..mapfiles fromdistbefore deploying, so they are never served even if someone guesses the URL.Gotcha: if the upload needs a token from
.env.local, hosted builds (Vercel, Netlify, CI) don't have that file. The build still passes and the upload is quietly skipped. Put the token in the host's environment variables too.Question: do you do steps 2 and 3 in a Vite plugin (
closeBundle) or as a separate script aftervite build?(Disclosure: I'm building Relia, a monitoring tool (https://tryrelia.com/?utm_source=vite-show-and-tell&utm_medium=community&utm_campaign=places); its Vite plugin does steps 2 and 3, and this is the reasoning behind it.)
All reactions