main.js 1.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748
  1. const path = require("path");
  2. const IconsDir = path.join(__dirname, "..", "icons");
  3. module.exports = {
  4. stories: ["../stories/**/*.stories.(js|jsx|ts|tsx|mdx)"],
  5. addons: [
  6. "@storybook/addon-actions",
  7. "@storybook/addon-links",
  8. "@storybook/addon-knobs",
  9. "@storybook/addon-storysource",
  10. "storybook-addon-jsx/register",
  11. "@storybook/addon-docs",
  12. ],
  13. webpackFinal: async (config) => {
  14. // Disable the Storybook internal-`.svg`-rule for components loaded from our app.
  15. const svgRule = config.module.rules.find((rule) => "test.svg".match(rule.test));
  16. svgRule.exclude = [IconsDir];
  17. config.module.rules.push({
  18. test: /\.svg$/i,
  19. include: [IconsDir],
  20. use: [
  21. {
  22. loader: "@svgr/webpack",
  23. options: {},
  24. },
  25. ],
  26. });
  27. config.module.rules.push({
  28. test: /\.(ts|tsx)$/,
  29. use: [
  30. {
  31. loader: require.resolve("babel-loader"),
  32. options: {
  33. rootMode: "upward",
  34. },
  35. },
  36. // Optional
  37. {
  38. loader: require.resolve("react-docgen-typescript-loader"),
  39. },
  40. ],
  41. });
  42. config.resolve.extensions.push(".ts", ".tsx");
  43. return config;
  44. },
  45. };