Skip to content

Unable to reference asset.input directory from Scss without relative path #28047

@david-kirkland

Description

@david-kirkland

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

Don't known / other

Is this a regression?

Yes

Description

We should be able to reference static files from architect.build.options.assets.input in SCSS without relative paths.

Default config...

// angular.json

  "projects": {
    "my-app": {
      "architect": {
        "build": {
          "options": {
            "assets": [
              {
                "glob": "**/*",
                "input": "public"
              }
            ]

Static files in the public directory can be referenced anywhere in the app without a relative path. For example, this does render without issue...

// app.component.html

<img src="background.jpg" />

Errors are thrown when the same static files are referenced from SCSS...

// styles.scss

html {
  background-image: url("background.jpg");
}

Please provide a link to a minimal reproduction of the bug

https://github.com/david-kirkland/ng-bug-public-scss/

Please provide the exception or error you saw

X [ERROR] Could not resolve "background.jpg" [plugin angular-css-resource]

    src/styles.scss:3:24:
      3 │   background-image: url("background.jpg");
        ╵                         ~~~~~~~~~~~~~~~~

  You can mark the path "background.jpg" as external to exclude it from the bundle, which will remove this error and leave the unresolved path in the bundle.
  Preprocessor stylesheets may not show the exact file location of the error.

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

Angular CLI: 18.1.0
Node: 22.4.1
Package Manager: npm 10.8.1
OS: Windows 10 Enterprise

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