Last active
September 18, 2025 17:43
-
-
Save f0rmat1k/dc24e7a4d76743bd58146a2175b30835 to your computer and use it in GitHub Desktop.
Storybook 9 + svgr
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| const config: StorybookConfig = { | |
| stories: ['../src/**/*.mdx', '../src/**/*.stories.@(js|jsx|mjs|ts|tsx)'], | |
| addons: [ | |
| '@storybook/addon-webpack5-compiler-swc', | |
| '@storybook/addon-docs', | |
| ], | |
| framework: { | |
| name: '@storybook/react-webpack5', | |
| options: {}, | |
| }, | |
| webpackFinal: async (config) => { | |
| config?.module?.rules?. | |
| filter(rule => typeof rule === 'object' && rule !== null && 'test' in rule && typeof rule.test === 'object' && 'test' in rule.test && rule?.test?.test('.svg')). | |
| forEach(rule => { | |
| if (typeof rule === 'object' && rule !== null) { | |
| rule.exclude! = /\.svg$/i; | |
| } | |
| }); | |
| config.module?.rules?.push({ | |
| test: /\.svg$/i, | |
| issuer: /\.[jt]sx?$/, | |
| use: ['@svgr/webpack'], | |
| }); | |
| return config; | |
| }, | |
| }; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment