Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Support for gulpfile written in ES6 #16

Open
cmwd opened this issue Aug 21, 2015 · 3 comments
Open

Support for gulpfile written in ES6 #16

cmwd opened this issue Aug 21, 2015 · 3 comments

Comments

@cmwd
Copy link

cmwd commented Aug 21, 2015

Gulp since version 3.9 supports gulpfile written in es6 (babel). It would be great if gulp-chug could support babel. Right now I getting syntax error. Update dependency to new version of gulp didn't help.

@03eltond
Copy link

I agree it would be nice if it would "just work" out of the box, but in the meantime I found a workaround using the nodeCmd option to use babel-node:

return gulp.src(path.resolve(__dirname, '../other-project/gulpfile.babel.js'))
    .pipe(chug({
        // Specify babel-node for ES6 support
        nodeCmd: path.resolve(__dirname, 'node_modules/.bin/babel-node.cmd')
    }))
    .on('error', gutil.log);

The .cmd after babel-node is needed on Windows, but you'd want to drop that on any other OS. If you don't have babel-node installed,

npm i --save-dev babel-cli

should pull it down.

@trainerbill
Copy link

I came across this issue today and @03eltond workaround did work but it shouldn't be needed. I already have a .babelrc in the directory with the gulp file. I ended up just spawning my own process and it actually worked better and faster than this plugin.

import { exec } from 'child_process';
import map from 'map-stream';

function buildModules() {
  return gulp.src(['./modules/*/gulpfile.babel.js'])
          .pipe(map(function (file, cb) {
            exec('gulp --gulpfile ' + file.path, function(error, stdout, stderr) {
              console.log(stdout);
              cb();
            });
          }));
}
buildModules.displayName = 'build';
gulp.task(buildModules);

May help someone else

@03eltond
Copy link

Huh that's clever, thanks for sharing

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants