angularsasstsconfigangular-compiler-cli

Angular - How to import a scss variable file using ngc -w?


I've got a FooComponent that has a .scss file attached to it, this works.

However, when trying to import a variable file from an external lib residing in node_modules, it throws an error.

In my .scss file I do:

@import './node_modules/@my-lib/dist/utils/_exports';

But when I run ngc -w tsconfig-aot.json it throws:

Couldn't resolve resource ./node_modules/@my-lib/dist/utils/_exports from /Users/chrillewoodz/my-project/@my-lib/ng/src/components/foo/foo.component.scss

The strange thing is that if I do ngc -p tsconfig-aot.json (notice the -p instead of -w) then it works.

Why is this happening?


Solution

  • Turns out it was as simple as having to use both -w and -p, the -p is for explicitly telling ngc which config to use. So without it it was using the default tsconfig.json file.