转储聚合物元件 [英] Transpiling a Polymer Element
问题描述
我正在使用$ polymer init
架设Polymer 1.x元素.这些元素不是聚合物应用.它们只是元素.
I'm scaffolding Polymer 1.x Elements using $ polymer init
. These elements are not Polymer applications. They are just elements.
我所有的元素都用ES6编码.我想将元素向下移植到ES5.
All my elements are coded in ES6. I'd like to transpile my elements down to ES5.
考虑到$ polymer build
不支持单个Element项目,我可以使用哪些解决方案来实现上述目标?
Considering that $ polymer build
does not support single Element projects, what solutions can I use to achieve the above?
推荐答案
将Polymer转换为es5的过程分为3个步骤:
Transpiling Polymer to es5 is done in 3 steps:
-
通过内联脚本和CSS来硫化您的元素:
vulcanize element.html --inline-script --inline-css > element.v.html
将输出放入 Cripser . Crisper是一种工具,可提取所有内联并创建独立的.js文件.
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
通过Babel运行独立的JS文件:
Run the standalone JS file through Babel:
babel element.js -o element.js
旧答案(错误):您需要直接使用 vulcanize .例如:
Old Answer(wrong):You need to use vulcanize directly. for instance:
vulcanize target.html > build.html
这篇关于转储聚合物元件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!