问题
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