Skip to content

SCSS imports fail when serving from src directory #7406

@intellix

Description

@intellix

Bug Report or Feature Request (mark with an x)

- [x] bug report -> please search issues before submitting
- [ ] feature request

Versions.

1.3.0

Repro steps.

  1. Create a project: ng new cli-scss-imports --style=scss && cd cli-scss-imports
  2. mkdir src/scss
  3. Add src/scss/_variables.scss
  4. Add an import inside src/app/app.component.scss for @import 'src/scss/variables';

Works: ng serve from cli-scss-imports
Fails: ng serve from cli-scss-imports/src

The log given by the failure.

ERROR in ./app/app.component.scss
Module build failed:
@import 'src/scss/variables';
^
      File to import not found or unreadable: src/scss/variables.
Parent style sheet: stdin
      in /Users/dominic/Sites/github/intellix/cli-scss-imports/src/app/app.component.scss (line 1, column 1)
Error:
@import 'src/scss/variables';
^
      File to import not found or unreadable: src/scss/variables.
Parent style sheet: stdin
      in /Users/dominic/Sites/github/intellix/cli-scss-imports/src/app/app.component.scss (line 1, column 1)
    at options.error (/Users/dominic/Sites/github/intellix/cli-scss-imports/node_modules/node-sass/lib/index.js:291:26)
 @ ./app/app.component.ts 18:17-48
 @ ./app/app.module.ts
 @ ./main.ts
 @ multi webpack-dev-server/client?http://localhost:4200 ./main.ts

Desired functionality.

ng commands search upwards through directories for an .angular-cli.json and then work. If someone was to accidentally do this inside a directory, it's unable to resolve SCSS imports and the error is confusing when you forgot you were in another directory

Mention any other details that might be useful.

Metadata

Metadata

Assignees

No one assigned

    Labels

    P3An issue that is relevant to core functions, but does not impede progress. Important, but not urgenteffort1: easy (hours)help wantedLabel noting an issue which the team is looking for contribution from the community to fixtype: bug/fix

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions