Last active
February 9, 2020 23:41
-
-
Save jessarcher/fc1a1bf87f8131b3beccc73b2209b667 to your computer and use it in GitHub Desktop.
Storybook config to replace the loader for SVG files
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
module.exports = { | |
webpackFinal: async config => { | |
// Remove 'svg' from the existing regex covering all images | |
const svgRule = config.module.rules.find(rule => typeof rule.test.test === 'function' && rule.test.test('.svg')); | |
svgRule.test = new RegExp(svgRule.test.source.replace('svg|', '')) | |
// Add a new rule for svg files only | |
config.module.rules.push({ | |
test: /\.svg$/, | |
use: [ | |
{ | |
loader: 'html-loader', | |
options: { | |
minimize: true | |
} | |
} | |
] | |
}); | |
return config | |
}, | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment