main.ts 1.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051
  1. /* eslint-env node */
  2. /* eslint import/no-nodejs-modules:0 */
  3. import path from 'path';
  4. import {StorybookConfig} from '@storybook/core-common';
  5. import babelConfig from '../babel.config';
  6. const toPath = (p: string) => path.join(process.cwd(), p);
  7. const config: StorybookConfig = {
  8. stories: ['../docs-ui/stories/**/*.stories.*'],
  9. core: {
  10. builder: 'webpack5',
  11. },
  12. addons: [
  13. {
  14. name: '@storybook/addon-essentials',
  15. options: {},
  16. },
  17. '@storybook/addon-a11y',
  18. '@storybook/addon-links',
  19. ],
  20. // For whatever reason the `babel` config override is not present in
  21. // storybooks StorybookConfig type.
  22. //
  23. // See https://github.com/storybookjs/storybook/issues/15502
  24. //
  25. // @ts-expect-error
  26. babel: babelConfig,
  27. // XXX(emotion11): Workaround because storybook still uses emotion 10
  28. // internally. See https://github.com/storybookjs/storybook/issues/13145
  29. webpackFinal: async webpackConf => ({
  30. ...webpackConf,
  31. resolve: {
  32. ...webpackConf?.resolve,
  33. alias: {
  34. ...webpackConf?.resolve?.alias,
  35. '@emotion/core': toPath('node_modules/@emotion/react'),
  36. '@emotion/styled': toPath('node_modules/@emotion/styled'),
  37. 'emotion-theming': toPath('node_modules/@emotion/react'),
  38. '@babel/preset-react': toPath('node_modules/@babel/preset-react'),
  39. },
  40. },
  41. }),
  42. };
  43. export default config;