Skip to content

Unable to resolve relative path in url in SCSS files after Angular 18 upgrade #28638

@NavneetVaid

Description

@NavneetVaid

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

Don't known / other

Is this a regression?

Yes

Description

Hi, I am trying to upgrade from angular 17 to angular 18. When i am trying to build i am getting errors of preprocessor where it is not able to resolve some relative paths. Image
So if you see it is not able to resolve the path inside url. Has something changed the way we need to import or add some configuration.

If i try to change the path from ../../images/profile-bg.png to /images/profile-bg.png it works fine. As this scss file is copied from a library present inside node_modules and pasted directly into our app, we cannot modify the path in scss.

I already have node_modules as a value in my stylePreprocessorOptions in angular.json

Please provide a link to a minimal reproduction of the bug

No response

Please provide the exception or error you saw

✘ [ERROR] Could not resolve "../../images/profile-bg.png" [plugin angular-css-resource]

<stdin>:10120:20:
  10120 │ ...background: url("../../images/profile-bg.png") top left no-r...
        ╵                    ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

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

Angular CLI: 18.2.8
Node: 22.6.0
Package Manager: yarn 1.22.19
OS: darwin arm64

Angular: 18.2.7
... animations, cdk, common, compiler, compiler-cli, core, forms
... language-service, platform-browser, platform-browser-dynamic
... router, upgrade

Package Version

@angular-devkit/architect 0.1802.7
@angular-devkit/build-angular 18.2.7
@angular-devkit/build-ng-packagr 0.1002.0
@angular-devkit/build-optimizer 0.1302.1
@angular-devkit/build-webpack 0.1802.7
@angular-devkit/core 18.2.7
@angular-devkit/schematics 18.2.7
@angular/cli 18.2.8
@schematics/angular 18.2.7
ng-packagr 18.2.1
rxjs 7.8.1
typescript 5.5.4
zone.js 0.14.3

Anything else?

No response

Metadata

Metadata

Assignees

No one assigned

    Labels

    needs: repro stepsWe cannot reproduce the issue with the information given

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions