1

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?

Chrillewoodz
  • 27,055
  • 21
  • 92
  • 175
  • If you are inside the component, ./node_modules will look inside the component folder, no ? – David Feb 05 '18 at 10:10
  • @David I don't think so since using `-p` works correctly. I have tried many other paths as well but none of them work. So I don't think the problem is with the path itself :/ – Chrillewoodz Feb 05 '18 at 10:12
  • try using `~` instead of `./node_modules/` like this `'~@my-lib/dist/utils/_exports'` – Sheki Feb 05 '18 at 10:15

1 Answers1

0

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.

Chrillewoodz
  • 27,055
  • 21
  • 92
  • 175