简体   繁体   中英

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?

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.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM