Out Of Date Warning

This article was published on 10 Mar 2016, this means the content may be out of date or no longer relevant. You should verify that the technical information in this article is still current before relying upon it for your own purposes.

First, make sure we have the latest versions of both cli and local version of gulp:

$ gulp -v
CLI version 3.9.0
Local version 3.9.0

Creating an ES6 gulpfile

To use ES6 we need to have installed Babel as a dependency to our project, with es2015 plugin preset:

$ npm install babel-core babel-preset-es2015 --save-dev

We can specify preset with the command option or simply create .babelrc file:

    "presets": ["es2015"]

Then we need to tell gulp to use Babel.It can be done by renaming gulpfile.js to gulpfile.babel.js:

$ mv "gulpfile.js" "gulpfile.babel.js"

And that’s it. Now we can use ES6 syntax via Babel, for example some sort of gulpfile:

"use strict";
import gulp from gulp;

gulp.task("default", () => {
    console.log("From gulp!");