-
Notifications
You must be signed in to change notification settings - Fork 3
/
gulpfile.js
104 lines (91 loc) · 2.78 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
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
// grab our packages
var gulp = require("gulp"),
del = require("del"),
jsonTransform = require("gulp-json-transform"),
jshint = require("gulp-jshint"),
uglify = require("gulp-uglify"),
rename = require("gulp-rename"),
replace = require("gulp-replace"),
versionConfig = require("./version.json"),
npmConfig = require("./package.json"),
bowerConfig = require("./bower.json"),
ghPages = require("gulp-gh-pages");
// configure which files to watch and what tasks to use on file changes
gulp.task("watch", function () {
gulp.watch("src/*.js", ["jshint"]);
});
// configure the jshint task
gulp.task("jshint", function () {
return gulp
.src("src/*.js")
.pipe(jshint())
.pipe(jshint.reporter("jshint-stylish"));
});
// Clean the dist directory
gulp.task("clean:dist", function (cb) {
del(["dist/**/*"], cb);
});
// configure the build task
gulp.task("build", ["jshint", "clean:dist"], function (cb) {
return gulp.src("src/brewser.js").pipe(gulp.dest("dist"));
});
// configure the minified build task
gulp.task("build:min", ["build"], function (cb) {
return gulp
.src("src/brewser.js")
.pipe(uglify())
.pipe(rename({ extname: ".min.js" }))
.pipe(gulp.dest("dist"));
});
gulp.task("version:build", ["build:min"], function (cb) {
return gulp
.src("dist/brewser.js")
.pipe(replace("{{VERSION}}", versionConfig.version))
.pipe(gulp.dest("dist"));
});
gulp.task("version:build:min", ["version:build"], function (cb) {
return gulp
.src("dist/brewser.min.js")
.pipe(replace("{{VERSION}}", versionConfig.version))
.pipe(gulp.dest("dist"));
});
// Update the version number in the bower.json file using
// 'version.json'
gulp.task("version:npm", ["version:build:min"], function (cb) {
var contents = npmConfig;
contents.version = versionConfig.version;
return gulp
.src("./package.json")
.pipe(
jsonTransform(function (data) {
return contents;
}, 4)
)
.pipe(gulp.dest("./"));
});
// Update the version number in the bower.json file using 'version.json'
gulp.task("version:bower", ["version:npm"], function (cb) {
var contents = bowerConfig;
contents.version = versionConfig.version;
return gulp
.src("./bower.json")
.pipe(
jsonTransform(function (data) {
return contents;
}, 4)
)
.pipe(gulp.dest("./"));
});
// Copy the demo index file to dist
gulp.task("copy:demo", [], function (cb) {
return gulp.src("demo/**/*").pipe(gulp.dest("dist"));
});
// Deploy to GH Pages
gulp.task("deploy:dist", function () {
return gulp.src("./dist/**/*").pipe(ghPages());
});
// Define custom tasks
gulp.task("default", ["watch"]);
gulp.task("release", ["version:bower"]);
gulp.task("deploy:prepare", ["version:build:min", "copy:demo"]);
gulp.task("deploy", ["deploy:prepare", "deploy:dist"]);