[英]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.