How to publish Polymer 3.x custom element?

夙愿已清 提交于 2019-12-06 08:53:15

问题


I am learning 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).

I completed the requirements as mentioned in https://www.webcomponents.org,

  • included License file
  • tagged versions
  • added README file

But while doing "preview element" i got Error - 12: Missing bower.json. Currently, only Bower is supported. From Polymer version 3, the Polymer team recommends npm instead of Bower.

How to publish my polymer element, so I can use it in another app (like Angular app)?


回答1:


Publishing polymer 3 elements in webcomponents.org is not supported yet, it is on the roadmap

According to Polymer team:

The element catalog at webcomponents.org will be updated to support elements built with modules and distributed via npm.

But you can still just publish your element on npm

See How to Publish & Update a Package on npm




回答2:


You can already add elements published on npm to webcomponents.org, it's just the preview function that doesn't work

Once published on npm, you can just enter the name of your package on the publish page

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:

"repository": {
  "type": "git",
  "url": "https://github.com/your-name/your-package.git"
},


来源:https://stackoverflow.com/questions/52002062/how-to-publish-polymer-3-x-custom-element

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!