Skip to content

Instantly share code, notes, and snippets.

@f0rmat1k
Last active September 18, 2025 17:43
Show Gist options
  • Select an option

  • Save f0rmat1k/dc24e7a4d76743bd58146a2175b30835 to your computer and use it in GitHub Desktop.

Select an option

Save f0rmat1k/dc24e7a4d76743bd58146a2175b30835 to your computer and use it in GitHub Desktop.
Storybook 9 + svgr
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