-
Notifications
You must be signed in to change notification settings - Fork 3
/
Copy pathGulpfile.js
49 lines (45 loc) · 1.29 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
39
40
41
42
43
44
45
46
47
48
49
var gulp = require("gulp"),
plugins = require("gulp-load-plugins")(),
pkg = require("./package.json"),
config = {
banner: {
full: [
"/*!",
" * <%= pkg.name %> v<%= pkg.version %> - <%= pkg.description %>",
" * On the web at <%= pkg.homepage %>",
" * Written by <%= pkg.author %>",
" * Licensed under <%= pkg.license %>",
" */",
""
].join("\n"),
min: [
"/*! <%= pkg.name %> v<%= pkg.version %> | <%= pkg.license %> License | <%= pkg.homepage %> */",
""
].join("\n")
},
rename: {
suffix: ".min"
}
};
// lint + minify JS
gulp.task("build", ["clean"], function() {
return gulp.src("src/*")
.pipe(plugins.jshint())
.pipe(plugins.header(config.banner.full, { pkg: pkg }))
.pipe(gulp.dest("dist/"))
.pipe(plugins.uglify())
.pipe(plugins.header(config.banner.min, { pkg: pkg }))
.pipe(plugins.rename(config.rename))
.pipe(gulp.dest("dist/"));
});
// watch for changes and rebuild JS
gulp.task("watch", function() {
gulp.watch("src/*", ["build"]);
});
// clean dist/
gulp.task("clean", function() {
return gulp.src("dist/*", { read: false })
.pipe(plugins.clean());
});
// default
gulp.task("default", ["watch"]);