Angular component with svg template doesn't work with Storybook
See original GitHub issueCurrent Behavior
I have an Angular component which have a svg as template.
To make it work with Storybook, I have to add webpack configs with the svg-inline-loader
loader.
Expected Behavior
i want Storybook to work with Angular components which have svg templates.
Steps to Reproduce
I provided a minimal repo: https://github.com/Jad31/storybook-inline-svg-angular-issue.git
yarn
to install the dependenciesyarn run nx run svg-layout:storybook
Failure Logs
ModuleParseError: Module parse failed: Unexpected token (1:0)
You may need an appropriate loader to handle this file type, currently no loaders are configured to process this file. See https://webpack.js.org/concepts#loaders
> <svg [attr.viewBox]="viewbox.minx + ' ' + viewbox.miny + ' ' + viewbox.width + ' ' + viewbox.height">
| <svg:g
| workspace-svg-part
Environment
> yarn run nx report
yarn run v1.22.11
> NX Report complete - copy this into the issue template
Node : 14.19.0
OS : linux x64
yarn : 1.22.11
nx : 13.8.3
@nrwl/angular : 13.8.3
@nrwl/cli : 13.8.3
@nrwl/cypress : 13.8.3
@nrwl/detox : undefined
@nrwl/devkit : 13.8.3
@nrwl/eslint-plugin-nx : 13.8.3
@nrwl/express : undefined
@nrwl/jest : 13.8.3
@nrwl/js : undefined
@nrwl/linter : 13.8.3
@nrwl/nest : undefined
@nrwl/next : undefined
@nrwl/node : undefined
@nrwl/nx-cloud : undefined
@nrwl/react : undefined
@nrwl/react-native : undefined
@nrwl/schematics : undefined
@nrwl/storybook : 13.8.3
@nrwl/tao : 13.8.3
@nrwl/web : undefined
@nrwl/workspace : 13.8.3
typescript : 4.5.5
rxjs : 7.4.0
---------------------------------------
Community plugins:
@angular/animations: 13.2.4
@angular/common: 13.2.4
@angular/compiler: 13.2.4
@angular/core: 13.2.4
@angular/forms: 13.2.4
@angular/platform-browser: 13.2.4
@angular/platform-browser-dynamic: 13.2.4
@angular/router: 13.2.4
@angular-devkit/build-angular: 13.2.5
@angular/cli: 13.2.5
@angular/compiler-cli: 13.2.4
@angular/language-service: 13.2.4
@storybook/angular: 6.4.19
Done in 0.59s.
Issue Analytics
- State:
- Created 2 years ago
- Reactions:2
- Comments:6 (4 by maintainers)
Top Results From Across the Web
Is there a way to include local svg files into Storybook that I am ...
I have pushed a new rule to Storybook's webpack config file in main.js under .storybook folder and am using the svg-inline-loader for the...
Read more >External SVG use in Storybook (Angular) - Medium
Today I came across the issue to implement externally stored SVG icons in my Angular Storybook — here's my solution.
Read more >Import SVG Components in Storybook - Duncan Leung
I was running into an issue where SVG imports in Storybook were undefined instead of being imported as React components.
Read more >SVG as templates - Angular
You can use SVG files as templates in your Angular applications. When you use an SVG as the template, you are able to...
Read more >Controls Addon | Storybook: Frontend workshop for UI ...
Interact with component inputs dynamically in the Storybook UI. ... Github issues, and file a new issue if you don't find one that...
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 Free
Top 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
Hey @Coly010, the repo was set to private, sorry for that. It is now public.
Sorry for the bad explanation, i added webpack configs with the
svg-inline-loader
but it doesn’t resolve the issue, here is the problem.