Skip to content

No loader is configured for ".svg" (esbuild) #26336

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
noguespi opened this issue Nov 12, 2023 · 4 comments · Fixed by #26371
Closed

No loader is configured for ".svg" (esbuild) #26336

noguespi opened this issue Nov 12, 2023 · 4 comments · Fixed by #26371

Comments

@noguespi
Copy link

Command

build

Description

Please add the ability to import .svg in .ts with esbuild.

Example of use case:

import icons from "../assets/icons/icons.svg";

export class IconModule {
  constructor(iconRegistry: MatIconRegistry, sanitizer: DomSanitizer) {
    iconRegistry.addSvgIconSetLiteral(sanitizer.bypassSecurityTrustHtml(icons))
  }
}

In this specific use case we could use addSvgIconSetLiteral and an URL but the svg won't be part of the build anymore.

When it's part of the build we can have size stats about svg in our bundle and possibly get the .svg files hashed (cache busting), useful when you set multiple svg files inside a single svg using symbols (which angular component icon supports btw).

We could also import it directly in a template without having to create a svg component

Describe the solution you'd like

No response

Describe alternatives you've considered

As an alternative you can rename the .svg to .txt, it will be loaded using the esbuild text loader.

@KarlXOL
Copy link

KarlXOL commented Nov 12, 2023

Can't believe new build system has been released without having the option to at least configure this.
As it can be doe with custom-webpack, ...

@dgp1130 dgp1130 added feature Issue that requests a new feature angular/build:application labels Nov 14, 2023
@angular-robot angular-robot bot added the feature: votes required Feature request which is currently still in the voting phase label Nov 14, 2023
@alan-agius4 alan-agius4 removed feature Issue that requests a new feature feature: votes required Feature request which is currently still in the voting phase angular/build:application labels Nov 14, 2023
@alan-agius4
Copy link
Collaborator

This is working as expected since SVG is not a valid ESM Module.

@angular angular deleted a comment from angular-robot bot Nov 14, 2023
@KarlXOL
Copy link

KarlXOL commented Nov 14, 2023

This is working as expected since SVG is not a valid ESM Module.

It's not about "working as designed".
It's about missing functionality abailable in previous release of angular's toolpack, and making angular competitive compared to other SPA-Frameworks.

By the way, esbuild could be configured to deal with SVG. But in the way angular is integrating esbuild, there is possibility to configure esbuild loaders.

@angular-automatic-lock-bot
Copy link

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.

@angular-automatic-lock-bot angular-automatic-lock-bot bot locked and limited conversation to collaborators Dec 17, 2023
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
4 participants