forked from verlok/vanilla-lazyload
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathgulpfile.js
38 lines (35 loc) · 1.24 KB
/
gulpfile.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
var gulp = require("gulp");
var eslint = require("gulp-eslint");
var rollup = require("gulp-rollup");
var rename = require("gulp-rename");
var babel = require("gulp-babel");
var uglify = require("gulp-uglify");
var destFolder = "./dist";
gulp.task("default", function () {
process.env.NODE_ENV = "release";
return gulp.src("./src/**/*.js")
// ----------- linting --------------
.pipe(eslint())
.pipe(eslint.format())
.pipe(eslint.failAfterError()) // --> failing if errors
// ----------- rolling up --------------
.pipe(rollup({
format: "umd",
moduleName: "LazyLoad",
entry: "./src/lazyload.js"
}))
.pipe(rename("lazyload.es2015.js"))
.pipe(gulp.dest(destFolder)) // --> writing rolledup
// ----------- babelizing --------------
.pipe(babel())
.pipe(rename("lazyload.js"))
.pipe(gulp.dest(destFolder)) // --> writing babelized ES5
// ----------- minifying --------------
.pipe(uglify())
.pipe(rename("lazyload.min.js"))
.pipe(gulp.dest(destFolder)); // --> writing uglified
});
gulp.task("watch", function () {
gulp.watch("./src/**/*.js", ["default"]);
// Other watchers
});