Last active
March 11, 2023 09:52
-
-
Save d4rekanguok/986e12ed27b7b0b219425d40701836be to your computer and use it in GitHub Desktop.
Config Storybook to avoid conflicts with SVGR
This file contains 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 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; | |
}; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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 :