Skip to main content

Vite Plugin

Palette's Vite plugin uploads source maps to Palette.

Installation

npm install @palette.dev/plugin-vite

Usage

1. Update vite config

Update your Vite config's plugins and build configs:

Get your asset key at https://palette.dev/[your-username]/[your-project]/settings

vite.config.ts
import path from "path";
import { defineConfig } from "vite";
import palette from "@palette.dev/plugin-vite";

export default defineConfig({
plugins: [
// Add palette plugin
palette({
key: process.env.PALETTE_ASSET_KEY,
outputPath: "dist/assets",
}),
],
build: {
// Enable source maps
sourcemap: true,
rollupOptions: {
output: {
// Set source maps paths relative to the current working directory
sourcemapPathTransform: (relativeSourcePath, sourcemapPath) =>
path.relative(process.cwd(), path.resolve(path.dirname(sourcemapPath), relativeSourcePath)),
},
},
},
});

2. Add entrypoint

Import virtual:@palette.dev/plugin-vite/init in your app's entrypoint (e.g. main.js):

main.ts
import "virtual:@palette.dev/plugin-vite/init"; // import before other imports
import { init } from "@palette.dev/...";

init({
key: "...",
plugins: [
// ...
],
});

API

PropertyDescriptionTypeDefault
keyPalette asset keyboolean(required)
versionVersion of your appbooleangit commit hash
releaseMark version as release (see release docs)booleanif the current git branch is main or master or false
outputPathDirectory to search for source mapsstring
© 2024 Redraw, Inc.