-
Notifications
You must be signed in to change notification settings - Fork 5
/
gulpfile.js
96 lines (84 loc) · 2.2 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
/**
* Gulpfile for d3-components
*/
var gulp = require('gulp');
var header = require('gulp-header');
var concat = require('gulp-concat');
var rename = require('gulp-rename');
var uglify = require('gulp-uglify');
var ghPages = require('gulp-gh-pages');
var pug = require('gulp-pug');
var pkg = require('./package.json');
var version = pkg.version;
var banner = '/*! D3 Components v<%= version %> | (c) 2017 Zan Pan | MIT license */\n';
gulp.task('default', [
'concat-js',
'minify-js',
'compile-docs',
'watch'
]);
gulp.task('concat-js', function () {
gulp.src([
'src/js/core.js',
'src/js/bar-chart.js',
'src/js/pie-chart.js',
'src/js/line-chart.js',
'src/js/bubble-chart.js',
'src/js/radar-chart.js',
'src/js/sunburst-chart.js',
'src/js/choropleth-map.js',
'src/js/bubble-map.js',
'src/js/contour-plot.js',
'src/js/mosaic-plot.js',
'src/js/terrestrial-globe.js',
'src/js/tree-diagram.js',
'src/js/timeline-diagram.js',
'src/js/liquid-fill-gauge.js'
])
.pipe(concat('d3-components-' + version + '.js'))
.pipe(gulp.dest('dist/'))
.pipe(gulp.dest('docs/dist/'));
});
gulp.task('minify-js', ['concat-js'], function () {
gulp.src('dist/d3-components-' + version + '.js')
.pipe(uglify())
.pipe(header(banner, {
version : version
}))
.pipe(rename('d3-components-' + version + '.min.js'))
.pipe(gulp.dest('dist/'))
.pipe(gulp.dest('docs/dist/'));
});
gulp.task('compile-docs', function () {
gulp.src('src/docs/!(layout|links).pug')
.pipe(pug({
pretty: true
}))
.pipe(gulp.dest('docs/'));
gulp.src('src/docs/api/!(components).pug')
.pipe(pug({
pretty: true
}))
.pipe(gulp.dest('docs/api/'));
gulp.src('src/docs/gallery/!(links).pug')
.pipe(pug({
pretty: true
}))
.pipe(gulp.dest('docs/gallery/'));
});
gulp.task('watch', function () {
gulp.watch('src/js/*.js', [
'concat-js',
'minify-js'
]);
gulp.watch('src/docs/{*,*/}*.pug', [
'compile-docs'
]);
});
gulp.task('publish', function() {
return gulp.src('./docs/**/*')
.pipe(ghPages({
branch: 'gh-pages',
message: 'Update version ' + version
}));
});