Registry / devops / vite-plugin-turbosnap

vite-plugin-turbosnap

JSON →
library1.0.3jsnpmunverified

vite-plugin-turbosnap v1.0.3 generates a preview-stats.json file from Vite Storybook projects for Chromatic's Turbosnap feature, which limits snapshot runs to only changed stories. It works by constructing a dependency graph during Vite builds, mimicking webpack stats output for Chromatic CLI. Requires chromatic-cli >=6.5.0, Storybook >=7.0 (or 6.5 with @storybook/builder-vite >=0.1.22). Experimental; may not support all configurations.

npm install vite-plugin-turbosnap
INSTALL
IMPORT
SIG · VITE-PLUGIN-TURBOS
V
vite-plugin-turbosnap
devopsjavascriptv1.0.3
Install
—
Import
—
Disk
—
Pass rate
0/ 6
Env Coverage0 / 6
glibc
18–22
musl
18–22
Install & Compatibility
Where this runs
tested against v? · npm install
Install × environment matrix
Each cell = how many times install + import succeeded across repeated harness runs. Partial = flaky.
glibc = Debian/Ubuntu slim · musl = Alpine Linux
musl
node 18–226 runs
build_error
glibc
node 18–226 runs
build_error
Code
Verified usage

Verified import paths — ran on the pinned version, not inferred.

default
✓ import turbosnap from 'vite-plugin-turbosnap'
Default export is a function that returns a Vite plugin. No named exports.

Basic setup to add the turbosnap plugin only during production builds in Storybook's viteFinal config.

// .storybook/main.js import turbosnap from 'vite-plugin-turbosnap'; import { mergeConfig } from 'vite'; export default { stories: ['../src/**/*.stories.@(js|jsx|ts|tsx)'], addons: ['@storybook/addon-essentials'], framework: '@storybook/react-vite', async viteFinal(config, { configType }) { return mergeConfig(config, { plugins: configType === 'PRODUCTION' ? [ turbosnap({ rootDir: config.root ?? process.cwd(), }), ] : [], }); }, };
Debug
Known issues
gotchaPlugin must only be added in PRODUCTION mode, not during development.
fix
Conditionally apply plugin only when configType === 'PRODUCTION' as shown in the quickstart.
affects: >=1.0.0
gotcharootDir must point to the project root; in monorepos, process.cwd() may not be sufficient.
fix
Set rootDir to the monorepo package root, e.g., path.resolve(__dirname, '..').
affects: >=1.0.0
gotchaThe generated preview-stats.json is only produced during build-storybook, not dev.
fix
Run build-storybook to generate the file for Chromatic.
affects: >=1.0.0
Errors
Common errors & fixes
Error: The plugin 'vite-plugin-turbosnap' doesn't have the expected shape. Did you forget to call it?
Importing the plugin default incorrectly or not calling the function.
fix
Ensure the import is correct: import turbosnap from 'vite-plugin-turbosnap'; then use turbosnap({...}) in the plugins array.
Error: Cannot find module 'vite-plugin-turbosnap'
Package not installed or module resolution fails.
fix
Run npm install --save-dev vite-plugin-turbosnap and ensure node_modules path is correct.
Upgrade
Version history
1.0.3latest on npm
Audit
Dependencies

No dependency data recorded yet.

Agent activity
4 hits · last 30 days
node
4
Resources
vite-plugin-turbosnap — npm install vite-plugin-turbosnap · libregistry