问题
I'm scaffolding Polymer 1.x Elements using $ polymer init
. These elements are not Polymer applications. They are just elements.
All my elements are coded in ES6. I'd like to transpile my elements down to ES5.
Considering that $ polymer build
does not support single Element projects, what solutions can I use to achieve the above?
回答1:
Transpiling Polymer to es5 is done in 3 steps:
Vulcanize your element(s) by inlining the script and CSS:
vulcanize element.html --inline-script --inline-css > element.v.html
Pipe the output to Cripser. Crisper is a tool that extracts all inline and creates a standalone .js file.
crisper -s element.v.html -h element.v.html -j element.js
Run the standalone JS file through Babel:
babel element.js -o element.js
Old Answer(wrong):You need to use vulcanize directly. for instance:
vulcanize target.html > build.html
来源:https://stackoverflow.com/questions/44722220/transpiling-a-polymer-element