[英]How to publish Polymer 3.x custom element?
I am learning polymer3.x.我正在学习 polymer3.x。 I made a dummy polymer element.
我做了一个虚拟的聚合物元素。 Now i wanted to know how to publish online and use it in some other framework(eg: angular app).
现在我想知道如何在线发布并在其他一些框架(例如:angular app)中使用它。
I completed the requirements as mentioned in https://www.webcomponents.org ,我完成了https://www.webcomponents.org中提到的要求,
But while doing " preview element " i got Error - 12: Missing bower.json. Currently, only Bower is supported.
但是在执行“预览元素”时,我得到了
Error - 12: Missing bower.json. Currently, only Bower is supported.
Error - 12: Missing bower.json. Currently, only Bower is supported.
From Polymer version 3, the Polymer team recommends npm
instead of Bower
.从 Polymer 版本 3 开始,Polymer 团队推荐使用
npm
而不是Bower
。
How to publish my polymer element, so I can use it in another app (like Angular app)?如何发布我的聚合物元素,以便我可以在另一个应用程序(如 Angular 应用程序)中使用它?
Update 2更新 2
You can now publish your element on NPM and then use the web components page to publish it on the site您现在可以在 NPM 上发布您的元素,然后使用 Web 组件页面将其发布到网站上
Update 1更新 1
Publishing polymer 3 elements in webcomponents.org
is not supported yet, it is on the roadmap尚不支持在
webcomponents.org
中发布 polymer 3 元素,它在路线图上
According to Polymer team: 根据 Polymer 团队的说法:
The element catalog at webcomponents.org will be updated to support elements built with modules and distributed via npm.
将更新 webcomponents.org 上的元素目录以支持使用模块构建并通过 npm 分发的元素。
But you can still just publish your element on npm
但是你仍然可以在
npm
上发布你的元素
See How to Publish & Update a Package on npm 查看如何在 npm 上发布和更新包
You can already add elements published on npm to webcomponents.org, it's just the preview function that doesn't work你已经可以将 发布在 npm上的元素添加到 webcomponents.org,只是预览功能不起作用
Once published on npm, you can just enter the name of your package on the publish page在 npm 上发布后,您只需在发布页面上输入您的包的名称
One "problem" I have run into, is that you have to have a repository
field in your package.json
, otherwise webcomponents.org won't accept it, something like:我遇到的一个“问题”是,您必须在
package.json
中有一个repository
字段,否则 webcomponents.org 不会接受它,例如:
"repository": {
"type": "git",
"url": "https://github.com/your-name/your-package.git"
},
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.