简体   繁体   English

Angular-如何使用ngc -w导入scss变量文件?

[英]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. 我有一个FooComponent具有.scss连接到它的文件,这个工程。

However, when trying to import a variable file from an external lib residing in node_modules , it throws an error. 但是,当尝试从位于node_modules的外部lib导入变量文件时,它将引发错误。

In my .scss file I do: 在我的.scss文件中,我这样做:

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

But when I run ngc -w tsconfig-aot.json it throws: 但是当我运行ngc -w tsconfig-aot.json会抛出:

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. 奇怪的是,如果我执行ngc -p tsconfig-aot.json (请注意-p而不是-w ),那么它将起作用。

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. 事实证明,这与必须同时使用-w-p一样简单, -p用于显式告诉ngc使用哪个配置。 So without it it was using the default tsconfig.json file. 因此,如果没有它,它将使用默认的tsconfig.json文件。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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