SVG loader returns a string instead of a symbol object when loading from storybook
See original GitHub issueversions:
"svg-sprite-loader": "^3.7.3",
"svgo": "^1.0.5",
"svgo-loader": "^2.1.0",
"ts-loader": "^4.1.0",
"typescript": "^2.8.1",
"webpack": "^4.3.0",
"webpack-cli": "^2.0.13"
webpack configuration
{
test: /\.svg$/,
use: [
{
loader: 'svg-sprite-loader',
options: {
// extract: true,
spriteFilename: "icon.svg"
}
}, {
loader: 'svgo-loader',
options: {
plugins: [
{ removeTitle: true },
{ convertColors: { shorthex: false } },
{ convertPathData: false }
]
}
}]
}
When importing a sprite:
import * as education from "../src/assets/svg/education.svg";
instead of getting a symbol object as depicted here, I’m getting a url in the form of:
/static/media/education.3a3782a8.svg
I can’t seem to find the reason causing it. Thanks in advance.
Issue Analytics
- State:
- Created 5 years ago
- Comments:5 (1 by maintainers)
Top Results From Across the Web
SVG loader returns a string instead of a symbol object when ...
my workaround was to override the default rule set by applying my loaders directly onto their webpack override module, located under .storybook/ ...
Read more >React Storybook SVG Failed to execute 'createElement' on ...
This is the culprit, you need to make sure that the file load is excluding all inline SVG file otherwise it will error....
Read more >Import SVG Components in Storybook - Duncan Leung
Storybook Not Importing SVGs I was running into an issue where SVG imports in Storybook were instead of being imported as React components…...
Read more >svg-loader: A Different Way to Work With External SVG
Load external SVGs as inline elements. To address this, I have created a library called svg-loader. Simply put, it fetches the SVG files...
Read more >module build failed: typeerror [err_invalid_arg_type] - You.com
Module build failed: TypeError [ERR_INVALID_ARG_TYPE]: The "from" argument must be of type string. Received type undefined at D:\css-loader!
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
Probably due to a recent update, one of the webpack rules in the default storybook config has a
rule.test
that returns undefined now. I made a small tweak to the if statement:This is the full implementation if someone is interested: