简体   繁体   中英

How to publish Polymer 3.x custom element?

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. 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)?

Update 2

You can now publish your element on NPM and then use the web components page to publish it on the site


Update 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

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"
},

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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