Angular 18 Karma problem using loader svg in angular.json

Discussão em 'Angular' iniciado por GuiGui16, Janeiro 20, 2025.

  1. GuiGui16

    GuiGui16 Guest

    I and currently using Angular 18, and I couldn't upgrade to 19 yet. I tried to import .svg file in my .ts file and it work fine.

    This is how my angular.json look like

    "builder": "@ngx-env/builder:application",
    "options": {
    "outputPath": "dist/jv-b2b-frontend",
    "index": "src/index.html",
    "browser": "src/main.ts",
    "polyfills": ["zone.js"],
    "tsConfig": "tsconfig.app.json",
    "assets": ["src/favicon.ico", "src/assets", "src/assets/*"],
    "styles": ["src/styles.css"],
    "scripts": [],
    "sourceMap": true,
    "loader": {
    ".svg": "text"
    }
    }



    When I tried to ng test, I got the following error

    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.

    Continue reading...

Compartilhe esta Página