Skip to content

Angular-cli doesn't resolve relative paths for css imports #12981

@tamtakoe

Description

@tamtakoe

Bug Report or Feature Request (mark with an x)

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

Command (mark with an x)

- [ ] new
- [ ] build
- [x] serve
- [ ] test
- [ ] e2e
- [ ] generate
- [ ] add
- [ ] update
- [ ] lint
- [ ] xi18n
- [ ] run
- [ ] config
- [ ] help
- [ ] version
- [ ] doc

Versions

Ubuntu: 17.10
node: 11.1.0
npm: 6.4.1
ng: 7.0.6

Repro steps

Clean project, use SCSS by default.

style.scss (defined in the default angular.json)

@import 'styles/app.scss';

styles/app.scss

@import 'lib.css';

The log given by the failure

ERROR in ./src/styles.scss (./node_modules/@angular-devkit/build-angular/src/angular-cli-files/plugins/raw-css-loader.js!./node_modules/postcss-loader/src??embedded!./node_modules/sass-loader/lib/loader.js??ref--14-3!./src/styles.scss)
Module build failed (from ./node_modules/postcss-loader/src/index.js):
Error: Failed to find 'lib.css'
  in [
    /home/username/dev/angular-test/src
  ]
    at resolveModule.catch.catch (/home/username/dev/angular-test/node_modules/postcss-import/lib/resolve-id.js:35:13)

If add ./ prefix - the same result

Desired functionality

It works if lib.css imported by @import 'styles/lib.css'; but @import should be resolved by relative path

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions