{"id":20688,"library":"vite-plugin-turbosnap","title":"vite-plugin-turbosnap","description":"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.","status":"active","version":"1.0.3","language":"javascript","source_language":"en","source_url":"https://github.com/IanVS/vite-plugin-turbosnap","tags":["javascript","vite-plugin","chromatic","turbosnap","storybook","vite","snapshot","typescript"],"install":[{"cmd":"npm install vite-plugin-turbosnap","lang":"bash","label":"npm"},{"cmd":"yarn add vite-plugin-turbosnap","lang":"bash","label":"yarn"},{"cmd":"pnpm add vite-plugin-turbosnap","lang":"bash","label":"pnpm"}],"dependencies":[],"imports":[{"note":"Default export is a function that returns a Vite plugin. No named exports.","symbol":"default","correct":"import turbosnap from 'vite-plugin-turbosnap'"}],"quickstart":{"code":"// .storybook/main.js\nimport turbosnap from 'vite-plugin-turbosnap';\nimport { mergeConfig } from 'vite';\n\nexport default {\n  stories: ['../src/**/*.stories.@(js|jsx|ts|tsx)'],\n  addons: ['@storybook/addon-essentials'],\n  framework: '@storybook/react-vite',\n  async viteFinal(config, { configType }) {\n    return mergeConfig(config, {\n      plugins:\n        configType === 'PRODUCTION'\n          ? [\n              turbosnap({\n                rootDir: config.root ?? process.cwd(),\n              }),\n            ]\n          : [],\n    });\n  },\n};","lang":"javascript","description":"Basic setup to add the turbosnap plugin only during production builds in Storybook's viteFinal config."},"warnings":[{"fix":"Conditionally apply plugin only when configType === 'PRODUCTION' as shown in the quickstart.","message":"Plugin must only be added in PRODUCTION mode, not during development.","severity":"gotcha","affected_versions":">=1.0.0"},{"fix":"Set rootDir to the monorepo package root, e.g., path.resolve(__dirname, '..').","message":"rootDir must point to the project root; in monorepos, process.cwd() may not be sufficient.","severity":"gotcha","affected_versions":">=1.0.0"},{"fix":"Run build-storybook to generate the file for Chromatic.","message":"The generated preview-stats.json is only produced during build-storybook, not dev.","severity":"gotcha","affected_versions":">=1.0.0"}],"env_vars":null,"last_verified":"2026-04-25T00:00:00.000Z","next_check":"2026-07-24T00:00:00.000Z","problems":[{"fix":"Ensure the import is correct: import turbosnap from 'vite-plugin-turbosnap'; then use turbosnap({...}) in the plugins array.","cause":"Importing the plugin default incorrectly or not calling the function.","error":"Error: The plugin 'vite-plugin-turbosnap' doesn't have the expected shape. Did you forget to call it?"},{"fix":"Run npm install --save-dev vite-plugin-turbosnap and ensure node_modules path is correct.","cause":"Package not installed or module resolution fails.","error":"Error: Cannot find module 'vite-plugin-turbosnap'"}],"ecosystem":"npm","meta_description":null,"install_score":null,"install_tag":null,"quickstart_score":null,"quickstart_tag":null}