Created
March 22, 2022 09:04
-
-
Save fedek6/c91310ef129a8897c5c010e6543bafd8 to your computer and use it in GitHub Desktop.
Disable SVGR (SVGO) prefixes in Storybook
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"); | |
module.exports = { | |
stories: [ | |
"../stories/**/*.stories.mdx", | |
"../stories/**/*.stories.@(js|jsx|ts|tsx)", | |
], | |
addons: [ | |
"@storybook/addon-links", | |
"@storybook/addon-essentials", | |
"storybook-dark-mode", | |
], | |
framework: "@storybook/react", | |
core: { | |
builder: "webpack5", | |
}, | |
webpackFinal: async (config, { configType }) => { | |
// `configType` has a value of 'DEVELOPMENT' or 'PRODUCTION' | |
// You can change the configuration based on that. | |
// 'PRODUCTION' is used when building the static version of storybook. | |
config.resolve.alias = require("./packageAliases"); | |
const fileLoaderRule = config.module.rules.find( | |
(rule) => rule.test && rule.test.test(".svg") | |
); | |
fileLoaderRule.exclude = /\.svg$/; | |
config.module.rules.push({ | |
test: /\.svg$/, | |
enforce: "pre", | |
loader: require.resolve("@svgr/webpack"), | |
options: { | |
svgoConfig: { | |
plugins: [ | |
{ | |
name: "prefixIds", | |
active: false, | |
}, | |
], | |
}, | |
}, | |
}); | |
// Return the altered config | |
return config; | |
}, | |
}; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment