Module parsing failure on 'ng build' for SVG files in "assets"
See original GitHub issueπ Bug report
Command (mark with an x
)
- new
- build
- serve
- test
- e2e
- generate
- add
- update
- lint
- extract-i18n
- run
- config
- help
- version
- doc
Is this a regression?
Yes
Yes, the previous version in which this bug was not present was: ^11.0.0
Description
Build fails, the error message is misleading:
./node_modules/qms/core/assets/img/48x48/test.svg:1:0 - Error: 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 id="Image" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" viewBox="0 0 48 48">
| <defs>
| <linearGradient id="linear-gradient" x1="8.347" y1="12.268" x2="39.653" y2="43.573" gradientUnits="userSpaceOnUse">
π₯ Exception or Error
./node_modules/qms/core/assets/img/48x48/test.svg:1:0 - Error: 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 id="Image" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" viewBox="0 0 48 48">
| <defs>
| <linearGradient id="linear-gradient" x1="8.347" y1="12.268" x2="39.653" y2="43.573" gradientUnits="userSpaceOnUse">
π Your Environment
Angular CLI: 12.0.1
Node: 14.17.0
Package Manager: npm 7.13.0
OS: win32 x64
Angular: 12.0.1
... animations, cdk, cli, common, compiler, compiler-cli, core
... forms, platform-browser, platform-browser-dynamic, router
Package Version
---------------------------------------------------------
@angular-devkit/architect 0.1200.1
@angular-devkit/build-angular 12.0.1
@angular-devkit/core 12.0.1
@angular-devkit/schematics 12.0.1
@schematics/angular 12.0.1
ng-packagr 12.0.0
rxjs 6.6.7
typescript 4.2.4
Issue Analytics
- State:
- Created 2 years ago
- Comments:9 (1 by maintainers)
Top Results From Across the Web
Module parsing failed while trying to use SVG as background
I use webpack to create the web app. Error: ERROR in ./src/components/Areas/ReportDisplay/button.svg 1:0 Module parse failed: Unexpected token (Β ...
Read more >Assets loading with "require()" doesn't work anymore with v12
assets /img.svg:1:0 - Error: Module parse failed: Unexpected token (1:0) You may need an appropriate loader to handle this file type,Β ...
Read more >Angular CLI: Different ways to include assets - Εukasz Nojek
In this article I will discuss several methods of adding and referring to static files in an Angular CLI application β may they...
Read more >How To Use Custom SVG Icons in Angular Material
To use our custom unicorn icon with the <mat-icon> component tag, we'll need to import HttpClientModule . Open the app.module.ts file: nano src/Β ......
Read more >Angular package format
Developers can rely on Angular CLI and ng-packagr (a build tool Angular CLI uses) to ... It declares the package to be in...
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
@alan-agius4 : yes, require is there for each SVG.
If this is the root of the problem, then what is the solution? And also, why was this working in Angular 11?
This issue has been automatically locked due to inactivity. Please file a new issue if you are encountering a similar or related problem.
Read more about our automatic conversation locking policy.
This action has been performed automatically by a bot.