Skip to content

TemplateUrl, StyleUrl and StyleUrls absolute path not working anymore #30124

@Loic-fr

Description

@Loic-fr

Which @angular/* package(s) are the source of the bug?

Don't known / other

Is this a regression?

Yes

Description

With Angular 17, we used to use absolute path for TemplateUrl, StyleUrl and/or StyleUrls to allow sharing of templates and style between components by using :
templateUrl: '/src/app/shared/some.component.html',

Since Angular 19, these paths don't work anymore and we had to use a lot of ../ to point to the file we need.

Angular documentation seem to indicate absolute paths should be possible :
https://angular.dev/api/core/Component#templateUrl

Please provide a link to a minimal reproduction of the bug

https://stackblitz.com/edit/stackblitz-starters-54tuykux?file=tsconfig.json

Please provide the exception or error you saw

TS-992008: Could not find stylesheet file '/src/app/shared/some.component.css'
and
TS-992008: Could not find template file '/src/app/shared/some.component.html'

Please provide the environment you discovered this bug in (run ng version)

Angular CLI: 19.2.1
Node: 20.11.1
Package Manager: npm 10.2.4
OS: win32 x64

Angular: 19.2.1
... animations, build, cli, common, compiler, compiler-cli, core
... forms, language-service, platform-browser
... platform-browser-dynamic, router, service-worker

Package                      Version
------------------------------------------------------
@angular-devkit/core         19.2.1
@angular-devkit/schematics   19.2.1
@angular/cdk                 19.2.2
@schematics/angular          19.2.1
rxjs                         7.8.2
typescript                   5.8.2
zone.js                      0.15.0

Anything else?

No response

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