main.ts 2.4 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364
  1. import type { StorybookConfig } from '@storybook/react-vite';
  2. import { dirname, resolve } from 'path';
  3. import { vendureDashboardPlugin } from '@vendure/dashboard/vite';
  4. import { fileURLToPath, pathToFileURL } from 'url';
  5. import { extractJSDocPlugin } from './extract-jsdoc-plugin.js';
  6. import { transformJSDocPlugin } from './transform-jsdoc-plugin.js';
  7. const __dirname = dirname(fileURLToPath(import.meta.url));
  8. const config: StorybookConfig = {
  9. stories: ['./stories/Intro.mdx', './stories/*.mdx', '../src/**/*.stories.@(js|jsx|mjs|ts|tsx)'],
  10. addons: ['@storybook/addon-docs', '@storybook/addon-a11y'],
  11. framework: {
  12. name: '@storybook/react-vite',
  13. options: {},
  14. },
  15. core: {
  16. builder: '@storybook/builder-vite',
  17. },
  18. typescript: {
  19. reactDocgen: 'react-docgen-typescript',
  20. reactDocgenTypescriptOptions: {
  21. shouldExtractLiteralValuesFromEnum: true,
  22. shouldRemoveUndefinedFromOptional: true,
  23. propFilter: prop => {
  24. // Filter out props from node_modules
  25. if (prop.parent) {
  26. return !prop.parent.fileName.includes('node_modules');
  27. }
  28. return true;
  29. },
  30. savePropValueAsString: true,
  31. },
  32. },
  33. async viteFinal(config) {
  34. const vendureConfigPath = pathToFileURL(resolve(__dirname, '../sample-vendure-config.ts'));
  35. return {
  36. ...config,
  37. plugins: [
  38. // Extract JSDoc descriptions from component files and inline into story metadata
  39. // Must run before other plugins to process withDescription() calls
  40. extractJSDocPlugin(),
  41. // Transform JSDoc in component files to remove custom tags (@description, @docsCategory, etc.)
  42. // for cleaner display in Storybook's auto-generated prop tables
  43. transformJSDocPlugin(),
  44. ...(config.plugins ?? []),
  45. vendureDashboardPlugin({
  46. vendureConfigPath,
  47. api: {
  48. host: 'https://demo.vendure.io',
  49. port: 443,
  50. },
  51. gqlOutputPath: resolve(__dirname, '../src/lib/graphql/'),
  52. tempCompilationDir: resolve(__dirname, '../.temp'),
  53. disablePlugins: { tanstackRouter: true },
  54. }),
  55. ],
  56. };
  57. },
  58. };
  59. export default config;