Skip to content

application stylePreprocessorOptions cannot detect paths from a library #15126

@jonathanlie

Description

@jonathanlie

🐞 Bug report

Command (mark with an x)

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

Is this a regression?

The behaviour worked in 8.0.3, and stopped working in 8.1.2.

Description

There is 1 application and 1 library. Let's call this application tenant and the library shared-lib.
A component in the tenant wants to import a stylesheet of a component from shared-lib. This particular stylesheet imports a CSS like so:

@import 'colors'; // the lib's ng-package.json styleIncludePaths is already configured.

This will compile just fine in the library.

Now there is a component in tenant that wants to import this particular stylesheet.
This used to work before by doing this:

  1. Import the stylesheet explicitly, in projects/tenant/components/tenant-util.component.ts
  styleUrls: [
    '../../../../shared-lib/src/lib/components/util.component.scss',
    './tenant-util.component.scss'
  ]
...
  1. Configure stylePreprocessorOptions in the tenant project settings.
"projects": {
    "tenant": {
           ...
           "stylePreprocessorOptions": {
              "includePaths": [
                "projects/shared-lib/src/lib/stylesheets"
              ]
            },

🔬 Minimal Reproduction

Clone this repo: https://github.com/jonathanlie/angular-demo

  1. To demonstrate the working version, inside the cloned repo:
git checkout angular-cli-8.0.3
npm install
ng build shared-lib
ng serve --aot tenant
  1. To demonstrate the non-working version
git checkout master
sudo rm -r ./node_modules
npm install
ng build shared-lib
ng serve --aot tenant

There will be an error when serving the tenant app as described in the section below.

🔥 Exception or Error


10% building 3/3 modules 0 activeℹ 「wds」: Project is running at http://localhost:4200/webpack-dev-server/
ℹ 「wds」: webpack output is served from /
ℹ 「wds」: 404s will fallback to //index.html

chunk {main} main.js, main.js.map (main) 2.07 kB [initial] [rendered]
chunk {polyfills} polyfills.js, polyfills.js.map (polyfills) 712 bytes [initial] [rendered]
chunk {runtime} runtime.js, runtime.js.map (runtime) 6.09 kB [entry] [rendered]
chunk {styles} styles.js, styles.js.map (styles) 17 kB [initial] [rendered]
chunk {vendor} vendor.js, vendor.js.map (vendor) 341 kB [initial] [rendered]
Date: 2019-07-19T06:18:00.166Z - Hash: d82cd3d8b42ac99436fa - Time: 1565ms

ERROR in Module build failed (from /angular-demo/node_modules/sass-loader/lib/loader.js):

@import 'colors';
       ^
      Can't find stylesheet to import.
  ╷
1 │ @import 'colors';
  │         ^^^^^^^^
  ╵
  stdin 1:9  root stylesheet
      in /angular-demo/projects/shared-lib/src/lib/components/util.component.scss (line 1, column 9)

🌍 Your Environment


Angular CLI: 8.1.2
Node: 12.3.1
OS: darwin x64
Angular: 8.1.2
... animations, cli, common, compiler, compiler-cli, core, forms
... language-service, platform-browser, platform-browser-dynamic
... router

Package                            Version
------------------------------------------------------------
@angular-devkit/architect          0.801.2
@angular-devkit/build-angular      0.801.2
@angular-devkit/build-ng-packagr   0.801.2
@angular-devkit/build-optimizer    0.801.2
@angular-devkit/build-webpack      0.801.2
@angular-devkit/core               8.1.2
@angular-devkit/schematics         8.1.2
@ngtools/json-schema               1.1.0
@ngtools/webpack                   8.1.2
@schematics/angular                8.1.2
@schematics/update                 0.801.2
ng-packagr                         5.3.0
rxjs                               6.4.0
typescript                         3.4.5
webpack                            4.35.2

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