Wednesday, 7 June 2017

Copy everything from public dir to public-production and transform JS with babel

I have this in a gulpfile:

let gulp = require('gulp');
let pump = require('pump');
let babel = require('gulp-babel');

gulp.task('compress', function (cb) {
  pump([
      gulp.src('public/**/*'),
      babel({
        ignore: ['public/lib/**/*','!*.js'],
        minified: false,
        plugins: ['transform-remove-console'],
        presets: ['env']
      }),
      gulp.dest('public-production')
    ],
    cb
  );
});

This will copy everything from public to public-production successfully, however here is the problem:

if I use: ignore: ['public/lib/**/*','!*.js']

then it will not transpile any .js file!

however if I use: ignore: ['public/lib/**/*']

then Babel will attempt to transpile non-js files.

How can I copy all files from the folder, but only transpile the .js files?

I would think that this would work!



via Alexander Mills

No comments:

Post a Comment