Last active
January 25, 2016 00:10
-
-
Save spalger/5bc9d47d120c30255b70 to your computer and use it in GitHub Desktop.
babel transform that unlinks deleted/renamed files
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import gulp from 'gulp' | |
import babel from 'gulp-babel' | |
import combiner from 'stream-combiner2' | |
import sourcemaps from 'gulp-sourcemaps' | |
import watch from 'gulp-watch' | |
import gulpif from 'gulp-if' | |
import del from 'del' | |
import vinylPaths from 'vinyl-paths' | |
gulp.task('default', function () { | |
const babelTransform = combiner.obj([ | |
sourcemaps.init(), | |
babel({ | |
stage: 1, | |
blacklist: ['regenerator'], | |
optional: ['runtime', 'bluebirdCoroutines'] | |
}), | |
sourcemaps.write('.') | |
]) | |
const unlinkEvent = ({ event }) => event === 'unlink' || event === 'unlinkDir' | |
return gulp.src('src/**/*') | |
.pipe(watch('src/**/*')) | |
.pipe(gulpif(/\.jsx?$/, babelTransform)) | |
.pipe(gulp.dest('bin')) | |
.pipe(gulpif(unlinkEvent, vinylPaths(del))) | |
}) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment