【发布时间】:2019-08-15 23:35:57
【问题描述】:
如您所知,“ng g library”方法可以帮助我们创建可重用组件的库。但是,如果我希望通过 Angular Elements 的支持将这些组件编译成 Web 组件呢?不仅如此,lib 中的每个组件都将被编译到自己的文件夹或 JS 文件中。如何配置可以让我实现这一目标的开发环境?
例如:
如果我创建一个Lib并添加一个自定义组件,我知道我可以编译它,生成一系列文件夹,例如esm5,esm2015,fesm5等。现在,问题是:如何添加,让我们对我的库说 30 个自定义组件,然后当我编译时,它会为每个组件创建一个文件夹,其中包含它们的 Web 组件版本......好像 Angular Elements 遍历了我的组件库并生成了 Web 组件版本他们每个人。
像这样:
lib/
lib/custom/comp1
lib/custom/comp2
lib/custom/comp3
lib/custom/comp4
变成类似的东西:
Dist/
Dist/custom/
Dist/custom/bundle
Dist/custom/esm5
Dist/custom/esm2015
Dist/custom/comp1_web_independend_component_version
Dist/custom/comp2_web_independend_component_version
Dist/custom/comp3_web_independend_component_version
Dist/custom/comp4_web_independend_component_version
我找到的最接近的解决方案是:
https://medium.com/@rahulsahay19/running-multiple-angular-elements-on-the-same-page-5949dac5523
我还请求 Angular CLI 团队提供帮助:
【问题讨论】:
-
是的,实际上我有。事实上,我想你可以认为我在 CLI 和 Elements 方面也很有经验。
-
我发现solution 你觉得很有希望。结果怎么样?
标签: angular angular-cli ng-packagr angular-elements