Skip to content

Instantly share code, notes, and snippets.

@d4rekanguok
Last active March 11, 2023 09:52
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save d4rekanguok/986e12ed27b7b0b219425d40701836be to your computer and use it in GitHub Desktop.
Save d4rekanguok/986e12ed27b7b0b219425d40701836be to your computer and use it in GitHub Desktop.
Config Storybook to avoid conflicts with SVGR
const path = require('path');
const pathToInlineSvg = path.resolve(__dirname, '../resources/icons');
module.exports = (_, _, defaultConfig) => {
const rules = defaultConfig.module.rules;
// modify storybook's file-loader rule to avoid conflicts with svgr
const fileLoaderRule = rules.find(rule => rule.test.test('.svg'));
fileLoaderRule.exclude = pathToInlineSvg;
rules.push({
test: /\.svg$/,
include: pathToInlineSvg,
use: [{
loader: '@svgr/webpack',
options: {
icon: true,
},
}],
});
return defaultConfig;
};
@zeghmouri
Copy link

zeghmouri commented Mar 11, 2023

Hey @d4rekanguok ,
I know that is an old code but I am wondering if it still working for Webpack5 ? because I am getting this error :

ERR! module.exports = (_, _, defaultConfig) => {
ERR!                      ^
ERR! 
ERR! SyntaxError: Duplicate parameter name not allowed in this context

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment