main.ts 1.7 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364
  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: ['../stories/**/*.stories.*'],
  9. framework: '@storybook/react',
  10. core: {
  11. builder: 'webpack5',
  12. },
  13. addons: [
  14. {
  15. name: '@storybook/addon-essentials',
  16. options: {},
  17. },
  18. '@storybook/addon-a11y',
  19. '@storybook/addon-links',
  20. '@storybook/addon-docs',
  21. 'storybook-dark-mode',
  22. ],
  23. features: {
  24. emotionAlias: false,
  25. babelModeV7: true,
  26. },
  27. // For whatever reason the `babel` config override is not present in
  28. // storybooks StorybookConfig type.
  29. //
  30. // See https://github.com/storybookjs/storybook/issues/15502
  31. //
  32. // @ts-expect-error
  33. babel: babelConfig,
  34. // XXX(emotion11): Workaround because storybook still uses emotion 10
  35. // internally. See https://github.com/storybookjs/storybook/issues/13145
  36. webpackFinal: webpackConf => ({
  37. ...webpackConf,
  38. resolve: {
  39. ...webpackConf?.resolve,
  40. alias: {
  41. ...webpackConf?.resolve?.alias,
  42. '@emotion/core': toPath('node_modules/@emotion/react'),
  43. '@emotion/styled': toPath('node_modules/@emotion/styled'),
  44. 'emotion-theming': toPath('node_modules/@emotion/react'),
  45. '@babel/preset-react': toPath('node_modules/@babel/preset-react'),
  46. },
  47. // See: https://github.com/storybookjs/storybook/issues/17458
  48. fallback: {
  49. ...webpackConf?.resolve?.fallback,
  50. assert: toPath('commonjs-assert'),
  51. },
  52. },
  53. }),
  54. };
  55. export default config;