API reference
@fixback/vite-plugin reference
The complete API of
@fixback/vite-plugin. It uploads your production build's
sourcemaps as part of vite build, so captured errors arrive with a symbolicated
code-area pointer and your pipeline gains no extra step. For the concept, see the Source maps guide.Install
npm install -D @fixback/vite-pluginimport { defineConfig } from "vite";import { fixbackSourcemaps } from "@fixback/vite-plugin";export default defineConfig({ plugins: [fixbackSourcemaps()],});That is the whole integration, as long as FIXBACK_SECRET_KEY is in the build's
environment. Set the same release in the SDK's release option so
captured stacks find these maps.
What it does
On vite build only — never during dev — after the bundle is written:
- Ensures sourcemaps exist. If you haven't set
build.sourcemap, it turns it on as'hidden': maps are emitted but not referenced by your JS, so nothing leaks to visitors. An explicitbuild.sourcemapis always respected. - Uploads every
*.js.map, keyed by release and~/-abstract path, authenticated with your Project secret key. - Prunes the uploaded maps from the build output so they aren't deployed.
The SSR pass of an SSR build is skipped; only the client build's maps upload.
Options
All optional — fixbackSourcemaps() works with just FIXBACK_SECRET_KEY set.
| Option | Default | Description |
|---|---|---|
release | $FIXBACK_RELEASE, else a CI commit SHA, else git HEAD SHA | Build identifier (1–100 visible characters, no spaces or slashes). |
injectRelease | true | Define the resolved release into the bundle as __FIXBACK_RELEASE__, so the SDK stamps it without a release option. An explicit release in init(), or your own define, still wins. |
secretKey | $FIXBACK_SECRET_KEY | Your Project's secret key (sk_…). |
apiUrl | $FIXBACK_API_URL, else the hosted API | Point at a self-hosted deployment. |
urlPrefix | ~/ | Where bundles are served relative to the site root, e.g. ~/static. |
deleteAfterUpload | delete unless sourcemap: true | Remove uploaded .map files after upload so they aren't served. |
ensureSourcemaps | true | When build.sourcemap is unset, turn on 'hidden' maps. |
strict | false | Fail the build on an upload problem, instead of warning and continuing. |
disable | false | Turn the plugin off entirely — handy for gating on an env var. |
silent | false | Silence the informational log lines. |
fixbackSourcemaps({ disable: !process.env.CI, // only upload from CI strict: true, // and fail the build if the upload fails})Notes
- Failures never break your deploy. A missing key, an unreachable API or a
failed upload is a warning by default. Set
strict: trueto make CI fail loudly instead. - Hidden maps are the safe default. With
'hidden'maps the.mapfiles aren't referenced by your JS, so pruning them after upload is clean. If you setbuild.sourcemap: truethe maps are referenced and would be served publicly; the plugin keeps them, to avoid a danglingsourceMappingURL, and warns. - Re-running is safe. Artifacts upsert per release and path, so re-deploying the same release doesn't duplicate.