webpack.config.js 1005 B

123456789101112131415161718192021222324252627282930313233343536
  1. const path = require('path');
  2. const SRC_PATH = path.join(__dirname, '../src');
  3. const STORIES_PATH = path.join(__dirname, '../stories');
  4. const STYLE_PATH = path.resolve(__dirname, '../style');
  5. //dont need stories path if you have your stories inside your src folder
  6. module.exports = ({ config }) => {
  7. config.module.rules.push({
  8. test: /\.(ts|tsx)$/,
  9. include: [SRC_PATH, STORIES_PATH],
  10. use: [
  11. {
  12. loader: require.resolve('awesome-typescript-loader'),
  13. options: {
  14. configFileName: './.storybook/tsconfig.json'
  15. }
  16. },
  17. { loader: require.resolve('react-docgen-typescript-loader') }
  18. ]
  19. });
  20. const fileLoaderRule = config.module.rules.find(rule =>
  21. rule.test.test('.svg')
  22. );
  23. fileLoaderRule.exclude = STYLE_PATH;
  24. config.module.rules.push({
  25. test: /\.svg$/,
  26. include: STYLE_PATH,
  27. // issuer: { test: /\.ts$/ },
  28. use: {
  29. loader: 'raw-loader'
  30. }
  31. });
  32. config.resolve.extensions.push('.ts', '.tsx');
  33. return config;
  34. };