Storybook framework for Vue 3 applications with Vite build tool integration.
—
Standalone Vite plugins for Vue 3 component processing, template compilation, and documentation generation that can be used independently of Storybook.
Main plugin function that provides an array of Vue 3 specific Vite plugins for Storybook integration.
/**
* Creates an array of Vite plugins for Vue 3 Storybook integration
* @returns Array of Promise<Plugin> containing Vue template compilation plugin
*/
function storybookVuePlugin(): Promise<Plugin>[];Configures Vue template compilation with proper bundler settings for Storybook.
/**
* Creates a Vite plugin for Vue template compilation
* @returns Promise<Plugin> - Vite plugin for template compilation
*/
async function templateCompilation(): Promise<Plugin>;Advanced documentation plugin using vue-component-meta (Volar) for modern component metadata extraction.
/**
* Creates a Vite plugin for component metadata extraction using vue-component-meta
* @param tsconfigPath - Path to TypeScript configuration file
* @returns Promise<Plugin> - Vite plugin for component documentation
*/
async function vueComponentMeta(tsconfigPath?: string): Promise<Plugin>;Legacy documentation plugin using vue-docgen-api for component metadata extraction.
/**
* Creates a Vite plugin for component metadata extraction using vue-docgen-api
* @returns Promise<Plugin> - Vite plugin for component documentation
*/
async function vueDocgen(): Promise<Plugin>;Additional internal functions used by the plugin system.
/**
* Creates the vue-component-meta checker for metadata extraction
* @param tsconfigPath - Path to TypeScript configuration file
* @returns Checker instance for component analysis
*/
async function createVueComponentMetaChecker(tsconfigPath?: string): Promise<Checker>;
/**
* Component metadata structure extracted by vue-component-meta
*/
interface MetaSource {
exportName: string;
displayName: string;
sourceFiles: string;
props: PropMeta[];
events: EventMeta[];
slots: SlotMeta[];
exposed: ExposedMeta[];
}The template compilation plugin configures Vue with the ESM bundler build:
{
name: 'storybook:vue-template-compilation',
config: () => ({
resolve: {
alias: {
vue: 'vue/dist/vue.esm-bundler.js',
},
},
}),
}The vue-component-meta plugin provides:
The vue-docgen-api plugin provides:
.vue single-file componentsUse the plugins directly in your vite.config.ts:
import { defineConfig } from "vite";
import { storybookVuePlugin } from "@storybook/vue3-vite/vite-plugin";
export default defineConfig({
plugins: [
...storybookVuePlugin(),
// other plugins...
],
});The plugins are automatically configured based on framework options. For custom behavior, configure through the framework options:
// In .storybook/main.ts
import type { StorybookConfig } from "@storybook/vue3-vite";
const config: StorybookConfig = {
framework: {
name: "@storybook/vue3-vite",
options: {
docgen: {
plugin: "vue-component-meta",
tsconfig: "tsconfig.app.json"
}
}
}
};The vue-component-meta plugin filters files based on patterns:
// Included files
const include = /\.(vue|ts|js|tsx|jsx)$/;
// Excluded files
const exclude = /\.stories\.(ts|tsx|js|jsx)$|^\0\/virtual:|^\/virtual:|\.storybook\/.*\.(ts|js)$/;The plugin extracts comprehensive component metadata:
interface MetaSource {
exportName: string;
displayName: string;
sourceFiles: string;
props: PropMeta[];
events: EventMeta[];
slots: SlotMeta[];
exposed: ExposedMeta[];
}The vue-component-meta plugin includes comprehensive HMR support for live component metadata updates:
async handleHotUpdate({ file, read, server, modules, timestamp }) {
const content = await read();
checker.updateFile(file, content);
// Invalidate modules and trigger reload
const invalidatedModules = new Set<ModuleNode>();
for (const mod of modules) {
server.moduleGraph.invalidateModule(mod, invalidatedModules, timestamp, true);
}
server.ws.send({ type: 'full-reload' });
return [];
}HMR Features:
Install with Tessl CLI
npx tessl i tessl/npm-storybook--vue3-vite