我可以使用节点运行在ES6中编写的Gulp任务吗? [英] Can I run a Gulp task written in ES6 using Node?
问题描述
run-babel
脚本运行ES6脚本。所以,这将工作: node run-babel build.js //build.js写在ES6
但是现在我想从Gulp任务中访问这些ES6脚本之一,但是Gulp运行在vanilla节点上。
/ p>
有没有办法我可以在ES6中写Gulp任务
您可以先进入 node_modules / gulp / bin / gulp.js
并编辑第一行成为#!/ usr / bin / env node - -harmony
。这将在节点和谐模式下调用gulp。
然后你可以运行 node_modules / gulp / bin / gulp.js build
直接而不是 gulp build
。
如果你喜欢,你可以创建一个别名:)
I'm using ES6 on Node through Babel. I can run ES6 scripts using a run-babel
script. So, this will work:
node run-babel build.js //build.js is written in ES6
But now I'd like to access one of these ES6 scripts from a Gulp task but Gulp runs on vanilla node.
Is there a way I can write Gulp tasks in ES6
You can first go into node_modules/gulp/bin/gulp.js
and edit the first line to become #!/usr/bin/env node --harmony
. This will invoke gulp in node harmony mode.
Then you can run node_modules/gulp/bin/gulp.js build
directly instead of gulp build
.
You can make an alias if you like :)
这篇关于我可以使用节点运行在ES6中编写的Gulp任务吗?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!