main.js 1.5 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950
  1. const path = require('path')
  2. // NOTE: must be set before webpack config is imported
  3. process.env.SHARELATEX_CONFIG = path.resolve(
  4. __dirname,
  5. '../config/settings.webpack.js'
  6. )
  7. const customConfig = require('../webpack.config.dev')
  8. module.exports = {
  9. stories: [
  10. '../frontend/stories/**/*.stories.js',
  11. '../modules/**/stories/**/*.stories.js',
  12. ],
  13. addons: ['@storybook/addon-essentials', '@storybook/addon-a11y'],
  14. webpackFinal: storybookConfig => {
  15. // Combine Storybook's webpack loaders with our webpack loaders
  16. const rules = [
  17. // Filter out the Storybook font file loader, which overrides our font
  18. // file loader causing the font to fail to load
  19. ...storybookConfig.module.rules.filter(
  20. rule => !rule.test.toString().includes('woff')
  21. ),
  22. // Replace the less rule, adding to-string-loader
  23. // Filter out the MiniCSS extraction, which conflicts with the built-in CSS loader
  24. ...customConfig.module.rules.filter(
  25. rule =>
  26. !rule.test.toString().includes('less') &&
  27. !rule.test.toString().includes('css')
  28. ),
  29. {
  30. test: /\.less$/,
  31. use: ['to-string-loader', 'css-loader', 'less-loader'],
  32. },
  33. ]
  34. // Combine Storybook's webpack plugins with our webpack plugins
  35. const plugins = [...storybookConfig.plugins, ...customConfig.plugins]
  36. return {
  37. ...storybookConfig,
  38. module: {
  39. ...storybookConfig.module,
  40. rules,
  41. },
  42. plugins,
  43. }
  44. },
  45. }