我可以使用节点运行在ES6中编写的Gulp任务吗? [英] Can I run a Gulp task written in ES6 using Node?

查看:123
本文介绍了我可以使用节点运行在ES6中编写的Gulp任务吗?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在通过Babel在Node上使用ES6。我可以使用 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屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆