Skip to content

Relative url('..') in scss files cannot be resolved #5752

@httpdigest

Description

@httpdigest
- [X] bug report -> please search issues before submitting
- [ ] feature request

Versions.

Output from: ng --version:

    _                      _                 ____ _     ___
   / \   _ __   __ _ _   _| | __ _ _ __     / ___| |   |_ _|
  / △ \ | '_ \ / _` | | | | |/ _` | '__|   | |   | |    | |
 / ___ \| | | | (_| | |_| | | (_| | |      | |___| |___ | |
/_/   \_\_| |_|\__, |\__,_|_|\__,_|_|       \____|_____|___|
               |___/
@angular/cli: 1.0.0
node: 7.8.0
os: win32 x64
@angular/common: 4.0.1
@angular/compiler: 4.0.1
@angular/core: 4.0.1
@angular/forms: 4.0.1
@angular/http: 4.0.1
@angular/platform-browser: 4.0.1
@angular/platform-browser-dynamic: 4.0.1
@angular/router: 4.0.1
@angular/cli: 1.0.0
@angular/compiler-cli: 4.0.1

Repro steps.

  • ng new url-test
  • cd url-test
  • in .angular-cli.json change the "styles.css" to "styles.scss" and change the defaults/styleExt from "css" to "scss"
  • rename src/styles.css to src/styles.scss
  • add the two new folders: src/theme/images and src/theme/styles
  • add a new file src/theme/styles/mystyle.scss with the content: body { background: url('../images/background.png'); }
  • add a new file src/theme/images/background.png being any PNG image
  • add the following to src/styles.scss: @import './theme/styles/mystyle.scss';
  • run ng build
  • observe that the output is:

The log given by the failure.

ERROR in ./~/css-loader?{"sourceMap":false,"importLoaders":1}!./~/postcss-loader!./~/sass-loader!./src/styles.scss
Module not found: Error: Can't resolve '../images/background.png' in 'some/absolute/path/to/ng4-test/src'
 @ ./~/css-loader?{"sourceMap":false,"importLoaders":1}!./~/postcss-loader!./~/sass-loader!./src/styles.scss 6:56-91
 @ ./src/styles.scss
 @ multi ./src/styles.scss

Desired functionality.

What would [you] like to see implemented?

Currently, the behaviour when specifically using SCSS is different from using CSS. When using CSS (styles.css and mystyle.css) then everything works and the background.png image is found.
This should be the same when using SCSS.

What is the usecase?
Using SCSS instead of CSS for more expressiveness in an obviously more complex application than the one provided here.

Metadata

Metadata

Assignees

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