Skip to content

Angular 10: not able to use an image from assets in url() in scss files #18013

Closed
@destus90

Description

@destus90

🐞 Bug report

Command (mark with an x)

  • new
  • build
  • serve
  • test
  • e2e
  • generate
  • add
  • update
  • lint
  • xi18n
  • run
  • config
  • help
  • version
  • doc

Is this a regression?

Yes, the previous version in which this bug was not present was: 9

Description

There is no way to use an image from the assets folder with Angular 10. It works fine with v.9. Using the path as absolute /assets/logo.png resolves the issue, but it would not work with the base-href option.

🔬 Minimal Reproduction

  1. Clone it and try to run ng serve command. https://github.com/destus90/angular10-postcss-issue

🔥 Exception or Error




ERROR in ./src/app/app.component.scss
Module Error (from ./node_modules/postcss-loader/src/index.js):
Can't resolve './assets/logo.png'

🌍 Your Environment




Angular CLI: 10.0.0
Node: 14.2.0
OS: win32 x64

Angular: 10.0.0
... animations, cli, common, compiler, compiler-cli, core, forms
... localize, platform-browser, platform-browser-dynamic, router
Ivy Workspace: Yes

Package                           Version
-----------------------------------------------------------
@angular-devkit/architect         0.1000.0
@angular-devkit/build-angular     0.1000.0
@angular-devkit/build-optimizer   0.1000.0
@angular-devkit/build-webpack     0.1000.0
@angular-devkit/core              10.0.0
@angular-devkit/schematics        10.0.0
@ngtools/webpack                  10.0.0
@schematics/angular               10.0.0
@schematics/update                0.1000.0
rxjs                              6.5.5
typescript                        3.9.5
webpack                           4.43.0

Anything else relevant?

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