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

shell
npm install -D @fixback/vite-plugin
vite.config.ts
import { 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:

  1. 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 explicit build.sourcemap is always respected.
  2. Uploads every *.js.map, keyed by release and ~/-abstract path, authenticated with your Project secret key.
  3. 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.

OptionDefaultDescription
release$FIXBACK_RELEASE, else a CI commit SHA, else git HEAD SHABuild identifier (1–100 visible characters, no spaces or slashes).
injectReleasetrueDefine 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_KEYYour Project's secret key (sk_…).
apiUrl$FIXBACK_API_URL, else the hosted APIPoint at a self-hosted deployment.
urlPrefix~/Where bundles are served relative to the site root, e.g. ~/static.
deleteAfterUploaddelete unless sourcemap: trueRemove uploaded .map files after upload so they aren't served.
ensureSourcemapstrueWhen build.sourcemap is unset, turn on 'hidden' maps.
strictfalseFail the build on an upload problem, instead of warning and continuing.
disablefalseTurn the plugin off entirely — handy for gating on an env var.
silentfalseSilence the informational log lines.
ts
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: true to make CI fail loudly instead.
  • Hidden maps are the safe default. With 'hidden' maps the .map files aren't referenced by your JS, so pruning them after upload is clean. If you set build.sourcemap: true the maps are referenced and would be served publicly; the plugin keeps them, to avoid a dangling sourceMappingURL, and warns.
  • Re-running is safe. Artifacts upsert per release and path, so re-deploying the same release doesn't duplicate.