docs/_snippets/parameters-docs-source-transform-in-preview.md
// Replace your-framework with the framework you are using, e.g., nextjs-vite, vue3-vite, angular, sveltekit, etc.
import type { Preview } from '@storybook/your-framework';
const preview: Preview = {
parameters: {
docs: {
source: {
transform: async (source) => {
const prettier = await import('prettier/standalone');
const prettierPluginBabel = await import('prettier/plugins/babel');
const prettierPluginEstree = await import('prettier/plugins/estree');
return prettier.format(source, {
parser: 'babel',
plugins: [prettierPluginBabel, prettierPluginEstree],
});
},
},
},
},
};
export default preview;
export default {
parameters: {
docs: {
source: {
transform: async (source) => {
const prettier = await import('prettier/standalone');
const prettierPluginBabel = await import('prettier/plugins/babel');
const prettierPluginEstree = await import('prettier/plugins/estree');
return prettier.format(source, {
parser: 'babel',
plugins: [prettierPluginBabel, prettierPluginEstree],
});
},
},
},
},
};
// Replace your-framework with the framework you are using, e.g., nextjs, nextjs-vite, react-vite, etc.
import { definePreview } from '@storybook/your-framework';
const preview = definePreview({
parameters: {
docs: {
source: {
transform: async (source) => {
const prettier = await import('prettier/standalone');
const prettierPluginBabel = await import('prettier/plugins/babel');
const prettierPluginEstree = await import('prettier/plugins/estree');
return prettier.format(source, {
parser: 'babel',
plugins: [prettierPluginBabel, prettierPluginEstree],
});
},
},
},
},
});
export default preview;
// Replace your-framework with the framework you are using, e.g., nextjs, nextjs-vite, react-vite, etc.
import { definePreview } from '@storybook/your-framework';
const preview = definePreview({
parameters: {
docs: {
source: {
transform: async (source) => {
const prettier = await import('prettier/standalone');
const prettierPluginBabel = await import('prettier/plugins/babel');
const prettierPluginEstree = await import('prettier/plugins/estree');
return prettier.format(source, {
parser: 'babel',
plugins: [prettierPluginBabel, prettierPluginEstree],
});
},
},
},
},
});
export default preview;
import { definePreview } from '@storybook/vue3-vite';
const preview = definePreview({
parameters: {
docs: {
source: {
transform: async (source) => {
const prettier = await import('prettier/standalone');
const prettierPluginBabel = await import('prettier/plugins/babel');
const prettierPluginEstree = await import('prettier/plugins/estree');
return prettier.format(source, {
parser: 'babel',
plugins: [prettierPluginBabel, prettierPluginEstree],
});
},
},
},
},
});
export default preview;
import { definePreview } from '@storybook/vue3-vite';
const preview = definePreview({
parameters: {
docs: {
source: {
transform: async (source) => {
const prettier = await import('prettier/standalone');
const prettierPluginBabel = await import('prettier/plugins/babel');
const prettierPluginEstree = await import('prettier/plugins/estree');
return prettier.format(source, {
parser: 'babel',
plugins: [prettierPluginBabel, prettierPluginEstree],
});
},
},
},
},
});
export default preview;
import { definePreview } from '@storybook/angular';
const preview = definePreview({
parameters: {
docs: {
source: {
transform: async (source) => {
const prettier = await import('prettier/standalone');
const prettierPluginBabel = await import('prettier/plugins/babel');
const prettierPluginEstree = await import('prettier/plugins/estree');
return prettier.format(source, {
parser: 'babel',
plugins: [prettierPluginBabel, prettierPluginEstree],
});
},
},
},
},
});
export default preview;
import { definePreview } from '@storybook/web-components-vite';
const preview = definePreview({
parameters: {
docs: {
source: {
transform: async (source) => {
const prettier = await import('prettier/standalone');
const prettierPluginBabel = await import('prettier/plugins/babel');
const prettierPluginEstree = await import('prettier/plugins/estree');
return prettier.format(source, {
parser: 'babel',
plugins: [prettierPluginBabel, prettierPluginEstree],
});
},
},
},
},
});
export default preview;
import { definePreview } from '@storybook/web-components-vite';
const preview = definePreview({
parameters: {
docs: {
source: {
transform: async (source) => {
const prettier = await import('prettier/standalone');
const prettierPluginBabel = await import('prettier/plugins/babel');
const prettierPluginEstree = await import('prettier/plugins/estree');
return prettier.format(source, {
parser: 'babel',
plugins: [prettierPluginBabel, prettierPluginEstree],
});
},
},
},
},
});
export default preview;