Skip to content

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

Closed
@noguespi

Description

@noguespi

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.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions