github.com/pyroscope-io/pyroscope@v0.37.3-0.20230725203016-5f6947968bd0/.storybook/main.js (about) 1 const path = require('path'); 2 3 module.exports = { 4 stories: [ 5 '../stories/**/*.stories.mdx', 6 '../stories/**/*.stories.@(js|jsx|ts|tsx)', 7 ], 8 addons: ['@storybook/addon-links', '@storybook/addon-essentials'], 9 core: { 10 builder: 'webpack5', 11 }, 12 webpackFinal: async (config) => { 13 config.resolve.alias = { 14 ...config.resolve.alias, 15 // Only allow importing ui elements, since at some point we want to move 16 // ui to its own package 17 '@webapp/ui': path.resolve(__dirname, '../webapp/javascript/ui'), 18 '@ui': path.resolve(__dirname, '../webapp/javascript/ui'), 19 20 '@utils': path.resolve(__dirname, '../webapp/javascript/util'), 21 }; 22 config.resolve.extensions.push('.ts', '.tsx'); 23 24 // support sass 25 config.module.rules.push({ 26 test: /\.scss$/, 27 use: ['style-loader', 'css-loader', 'sass-loader'], 28 include: path.resolve(__dirname, '../'), 29 }); 30 31 // https://github.com/storybookjs/storybook/issues/6188#issuecomment-1026502543 32 // remove svg from existing rule 33 config.module.rules = config.module.rules.map((rule) => { 34 if ( 35 String(rule.test) === 36 String( 37 /\.(svg|ico|jpg|jpeg|png|apng|gif|eot|otf|webp|ttf|woff|woff2|cur|ani|pdf)(\?.*)?$/ 38 ) 39 ) { 40 return { 41 ...rule, 42 test: /\.(ico|jpg|jpeg|png|apng|gif|eot|otf|webp|ttf|woff|woff2|cur|ani|pdf)(\?.*)?$/, 43 }; 44 } 45 46 return rule; 47 }); 48 49 // This was copied from our main webpack config 50 config.module.rules.push({ 51 test: /\.svg$/, 52 use: [ 53 { 54 loader: 'react-svg-loader', 55 options: { 56 svgo: { 57 plugins: [ 58 { convertPathData: { noSpaceAfterFlags: false } }, 59 { removeViewBox: false }, 60 ], 61 }, 62 }, 63 }, 64 ], 65 }); 66 return config; 67 }, 68 };