Skip to content

Instantly share code, notes, and snippets.

@fedek6
Created March 22, 2022 09:04
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save fedek6/c91310ef129a8897c5c010e6543bafd8 to your computer and use it in GitHub Desktop.
Save fedek6/c91310ef129a8897c5c010e6543bafd8 to your computer and use it in GitHub Desktop.
Disable SVGR (SVGO) prefixes in Storybook
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