main.ts 1.3 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950
  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/components/*.stories.*'],
  9. core: {
  10. builder: 'webpack5',
  11. },
  12. addons: [
  13. {
  14. name: '@storybook/addon-essentials',
  15. options: {},
  16. },
  17. '@storybook/addon-a11y',
  18. ],
  19. // For whatever reason the `babel` config override is not present in
  20. // storybooks StorybookConfig type.
  21. //
  22. // See https://github.com/storybookjs/storybook/issues/15502
  23. //
  24. // @ts-expect-error
  25. babel: babelConfig,
  26. // XXX(emotion11): Workaround because storybook still uses emotion 10
  27. // internally. See https://github.com/storybookjs/storybook/issues/13145
  28. webpackFinal: async webpackConf => ({
  29. ...webpackConf,
  30. resolve: {
  31. ...webpackConf?.resolve,
  32. alias: {
  33. ...webpackConf?.resolve?.alias,
  34. '@emotion/core': toPath('node_modules/@emotion/react'),
  35. '@emotion/styled': toPath('node_modules/@emotion/styled'),
  36. 'emotion-theming': toPath('node_modules/@emotion/react'),
  37. '@babel/preset-react': toPath('node_modules/@babel/preset-react'),
  38. },
  39. },
  40. }),
  41. };
  42. export default config;