Skip to content

Commit

Permalink
fix: storybook icons, closes leather-io/issues#294
Browse files Browse the repository at this point in the history
  • Loading branch information
pete-watters committed Sep 3, 2024
1 parent 6b9566a commit c7c0b59
Showing 1 changed file with 34 additions and 0 deletions.
34 changes: 34 additions & 0 deletions .storybook/main.ts
Original file line number Diff line number Diff line change
Expand Up @@ -98,6 +98,40 @@ const config: StorybookConfig = {
chrome: [path.join(__dirname, '../tests/mocks/mock-chrome.ts'), 'chrome'],
})
);
config.module ??= {};
config.module.rules ??= [];
// This modifies the existing image rule to exclude `.svg` files
// so we can load it instead with @svgr/webpack
const imageRule = config.module.rules.find((rule: any) => {
if (rule && typeof rule !== 'string' && rule.test instanceof RegExp) {
return rule.test.test('.svg');
}
});
if (imageRule && typeof imageRule !== 'string') {
imageRule.exclude = /\.svg$/;
}
config.module.rules.push({
test: /\.svg$/,
use: [
{
loader: '@svgr/webpack',
options: {
svgoConfig: {
plugins: [
{
name: 'preset-default',
params: {
overrides: {
removeViewBox: false,
},
},
},
],
},
},
},
],
});
return config;
},
};
Expand Down

0 comments on commit c7c0b59

Please sign in to comment.