Can I run a Gulp task written in ES6 using Node?

廉价感情. 提交于 2019-12-13 00:29:13

问题


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


回答1:


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 :)



来源:https://stackoverflow.com/questions/29836529/can-i-run-a-gulp-task-written-in-es6-using-node

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!