Created
September 4, 2019 10:06
-
-
Save pavan-idapalapati/7054496bcf7e2ea30595a9ec0dd95c31 to your computer and use it in GitHub Desktop.
ES6 to ES5 gulp task
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
"use strict"; | |
import gulp from "gulp"; | |
import uglify from "gulp-uglify"; | |
import babel from "gulp-babel"; | |
const dirs = { | |
src: "src/*.js", | |
dest: "build" | |
} | |
gulp.task("build", () => { | |
return gulp.src(dirs.src) | |
.pipe(babel({ presets: ['es2015'] })) | |
.pipe(uglify()) | |
.pipe(gulp.dest(dirs.dest)); | |
}); | |
gulp.task("watch", () => { | |
gulp.watch(dirs.src, ["build"]); | |
}) | |
gulp.task("default", ["watch"]); | |
/* ========== .babelrc ============= | |
{ | |
"presets": ["es2015"] | |
} | |
======================================== | |
========== package.json ============ | |
"devDependencies": { | |
"babel-core": "^6.26.0", | |
"babel-preset-es2015": "^6.24.1", | |
"babel-register": "^6.26.0", | |
"gulp": "^3.9.1", | |
"gulp-babel": "^7.0.0", | |
"gulp-uglify": "^3.0.0" | |
} | |
======================================== |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment