main.ts 1.4 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152
  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. 'storybook-dark-mode',
  20. ],
  21. // For whatever reason the `babel` config override is not present in
  22. // storybooks StorybookConfig type.
  23. //
  24. // See https://github.com/storybookjs/storybook/issues/15502
  25. //
  26. // @ts-expect-error
  27. babel: babelConfig,
  28. // XXX(emotion11): Workaround because storybook still uses emotion 10
  29. // internally. See https://github.com/storybookjs/storybook/issues/13145
  30. webpackFinal: async webpackConf => ({
  31. ...webpackConf,
  32. resolve: {
  33. ...webpackConf?.resolve,
  34. alias: {
  35. ...webpackConf?.resolve?.alias,
  36. '@emotion/core': toPath('node_modules/@emotion/react'),
  37. '@emotion/styled': toPath('node_modules/@emotion/styled'),
  38. 'emotion-theming': toPath('node_modules/@emotion/react'),
  39. '@babel/preset-react': toPath('node_modules/@babel/preset-react'),
  40. },
  41. },
  42. }),
  43. };
  44. export default config;