Created
December 10, 2017 09:30
-
-
Save andfinally/ec68503ae4f619a7c549a25d0dae48c4 to your computer and use it in GitHub Desktop.
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 sass from 'gulp-sass'; | |
import babel from 'gulp-babel'; | |
import sourcemaps from 'gulp-sourcemaps'; | |
import es from 'event-stream'; | |
import rename from 'gulp-rename'; | |
import uglify from 'gulp-uglify'; | |
const sassOpts = {outputStyle: 'compressed', errLogToConsole: true}; | |
let riseError = (err) => { | |
console.log(err.toString()); | |
this.emit('end'); | |
}; | |
gulp.task('sass', () => { | |
gulp.src('./css/*.scss') | |
.pipe(sass(sassOpts)) | |
.pipe(gulp.dest('./css')); | |
}); | |
gulp.task('babel', () => { | |
return es.concat( | |
gulp.src('./js/*.es') | |
.pipe(sourcemaps.init()) | |
.pipe(babel({presets: ['es2015']})) | |
.on('error', riseError) | |
.pipe(gulp.dest('./js')) | |
.pipe(uglify()) | |
.pipe(rename((path) => path.extname = '.min.js')) | |
.pipe(sourcemaps.write('.')) | |
.pipe(gulp.dest('./js')) | |
); | |
}); | |
gulp.task('watch', () => { | |
gulp.watch('./css/*.scss', ['sass']); | |
gulp.watch('./js/*.es', ['babel']); | |
}); | |
gulp.task('default', ['sass', 'babel', 'watch']); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment