forked from xch89820/Chart.Funnel.js
-
Notifications
You must be signed in to change notification settings - Fork 17
/
Copy pathgulpfile.js
107 lines (98 loc) · 2.94 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
105
106
107
var gulp = require("gulp");
var rename = require("gulp-rename");
var jshint = require("gulp-jshint");
var replace = require("gulp-replace");
var insert = require("gulp-insert");
var streamify = require("gulp-streamify");
var browserify = require("browserify");
var uglify = require("gulp-uglifyes");
var concat = require("gulp-concat");
var source = require("vinyl-source-stream");
var merge = require("merge-stream");
var collapse = require("bundle-collapser/plugin");
var Server = require("karma").Server;
var buble = require("gulp-buble");
var package = require("./package.json");
var sourcemaps = require("gulp-sourcemaps");
var header =
"/*!\n" +
" * Chart.Funnel.js\n" +
" * A funnel plugin for Chart.js(http://chartjs.org/)\n" +
" * Version: {{ version }}\n" +
" *\n" +
" * Copyright 2016 Jone Casaper & YetiForce\n" +
" * Released under the MIT license\n" +
" * https://github.com/xch89820/Chart.Funnel.js/blob/master/LICENSE.md\n" +
" */\n";
gulp.task("js", function() {
// Bundled library
var bundled = browserify("./src/chart.funnel.js", {
standalone: "Chart.Funnel"
})
.plugin(collapse)
.bundle()
.pipe(source("chart.funnel.bundled.js"))
.pipe(insert.prepend(header))
.pipe(streamify(replace("{{ version }}", package.version)))
.pipe(streamify(jshint()))
.pipe(jshint.reporter("default"))
.pipe(gulp.dest("dist"))
.pipe(streamify(uglify()))
.pipe(insert.prepend(header))
.pipe(streamify(replace("{{ version }}", package.version)))
.pipe(streamify(concat("chart.funnel.bundled.min.js")))
.pipe(gulp.dest("dist"));
var nonBundled = browserify("./src/chart.funnel.js", {
standalone: "Chart.Funnel"
})
.ignore("chart.js")
.plugin(collapse)
.bundle()
.pipe(source("chart.funnel.js"))
.pipe(insert.prepend(header))
.pipe(streamify(replace("{{ version }}", package.version)))
.pipe(streamify(jshint()))
.pipe(jshint.reporter("default"))
.pipe(gulp.dest("dist"))
.pipe(streamify(uglify()))
.pipe(insert.prepend(header))
.pipe(streamify(replace("{{ version }}", package.version)))
.pipe(streamify(concat("chart.funnel.min.js")))
.pipe(gulp.dest("dist"));
return merge(bundled, nonBundled);
});
gulp.task("jshint", function() {
return gulp
.src("src/**/*.js")
.pipe(jshint("config.jshintrc"))
.pipe(jshint.reporter("jshint-stylish"))
.pipe(jshint.reporter("fail"));
});
gulp.task("compile-min", () =>
gulp
.src("dist/chart.funnel.js")
.pipe(sourcemaps.init())
.pipe(
rename({
suffix: ".min"
})
)
.pipe(uglify())
.pipe(buble())
.pipe(sourcemaps.write("."))
.pipe(gulp.dest("dist"))
);
// For CI
gulp.task("unittest.ci", function(done) {
new Server(
{
configFile: __dirname + "/karma.conf.ci.js",
singleRun: true
},
done
).start();
});
gulp.task("test.ci", ["jshint", "unittest.ci"]);
gulp.task("default", function() {
gulp.watch("src/**/*.js", ["js"]);
});