forked from jbdemonte/gmap3
-
Notifications
You must be signed in to change notification settings - Fork 0
/
gulpfile.js
74 lines (65 loc) · 1.83 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
var gulp = require("gulp");
var foreach = require('gulp-foreach');
var replace = require("gulp-replace");
var rename = require("gulp-rename");
var clean = require("gulp-clean");
var runSequence = require("run-sequence");
var uglify = require("gulp-uglify");
/**
* Remove dist directory
*/
gulp.task("clean", function () {
return gulp.src("dist", {read: false}).pipe(clean());
});
/**
* Copy example assets
*/
gulp.task("assets", function () {
// process each example but the template
return gulp.src(["src/examples/**/*.png", "src/examples/**/*.css"])
.pipe(gulp.dest("dist/examples/"));
});
/**
* Build example files using the template file
*/
gulp.task("examples", ["assets"], function () {
// process each example but the template
return gulp.src(["src/examples/**/*.html", "!src/examples/_template.html"])
.pipe(foreach(function(stream, file){
return gulp.src("src/examples/_template.html") // use template file
.pipe(replace("[body]", file.contents.toString())) // replace template tag by example content
.pipe(rename(file.path.split('/').pop())); // rename template file as example file
}))
.pipe(gulp.dest("dist/examples/"));
});
/**
* Uglify gmap3.js
*/
gulp.task("uglify", function () {
return gulp.src("dist/gmap3.js")
.pipe(uglify({preserveComments: "some"}))
.pipe(rename("gmap3.min.js"))
.pipe(gulp.dest("dist/"));
});
/**
* Build gmap3.js
*/
gulp.task("main", function () {
return gulp.src("src/gmap3.js")
.pipe(gulp.dest("dist/"));
});
/**
* Build package
*/
gulp.task("default", function (done) {
runSequence("clean", "main", "uglify", "examples", done);
});
/**
* Watch files modifications and rebuild
**/
gulp.task("watch", function() {
gulp.start("default");
gulp.watch("src/**/*", function() {
gulp.start("default");
});
});