-
Notifications
You must be signed in to change notification settings - Fork 12
/
Copy pathgulpfile.js
111 lines (95 loc) · 3.04 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
108
109
110
'use strict';
var gulp = require('gulp');
var sourcemaps = require('gulp-sourcemaps');
var babel = require('gulp-babel');
var concat = require('gulp-concat');
var uglify = require('gulp-uglify');
var cached = require('gulp-cached');
var remember = require('gulp-remember');
var sass = require('gulp-sass')(require('sass'));
var nodemon = require('gulp-nodemon');
var baseScripts = [
'src/app.js',
'src/odn-client/build-url.js',
'src/odn-client/get-json.js',
'src/odn-client/odn-client.js',
'src/navigate/entity.js',
'src/navigate/search.js',
'src/api-badge/api-badge.js',
'src/api-badge/api-popup.js'
];
var mapScripts = [
'src/maps/expand-collapse-control.js',
'src/maps/legend-control.js',
'src/maps/tooltip-control.js',
'src/maps/view.js'
];
var autosuggestScripts = [
'src/autosuggest/autosuggest-sources.js',
'src/autosuggest/autosuggest-source.js',
'src/autosuggest/autosuggest-results.js',
'src/autosuggest/autosuggest.js',
];
function js(src, dest) {
return function() {
return gulp.src(src)
.pipe(cached(dest))
.pipe(sourcemaps.init())
.pipe(babel())
.pipe(remember(dest))
.pipe(concat(dest))
.pipe(uglify())
.pipe(sourcemaps.write('.'))
.pipe(gulp.dest('lib'));
};
}
var homeScripts = baseScripts
.concat(autosuggestScripts)
.concat([
'src/home-page-controller.js',
'src/home.js']);
gulp.task('home', js(homeScripts, 'home.min.js'));
var searchScripts = baseScripts
.concat(autosuggestScripts)
.concat([
'src/infinite-scroll.js',
'src/show-more-questions.js',
'src/mobile-menus.js',
'src/search.js' ]);
gulp.task('search', js(searchScripts, 'search.min.js'));
var entityScripts = baseScripts
.concat(autosuggestScripts)
.concat(mapScripts)
.concat([
'src/dataset-chart.js',
'src/infinite-scroll.js',
'src/show-more-questions.js',
'src/mobile-menus.js',
'src/entity.js']);
gulp.task('entity', js(entityScripts, 'entity.min.js'));
var datasetScripts = baseScripts
.concat(autosuggestScripts)
.concat([
'src/dataset.js']);
gulp.task('dataset', js(datasetScripts, 'dataset.min.js'));
gulp.task('js', gulp.series('home', 'search', 'dataset', 'entity'));
gulp.task('css', function() {
return gulp.src(['styles/**/*.scss', 'styles/**/*.sass'])
.pipe(sourcemaps.init())
.pipe(sass({outputStyle: 'compressed'}))
.pipe(sourcemaps.write('.'))
.pipe(gulp.dest('styles/compressed'));
});
gulp.task('build', gulp.series('js', 'css'));
gulp.task('watch', gulp.series('build'), function() {
gulp.watch('src/**/*.js', ['js']);
gulp.watch(['styles/*.sass', 'styles/*.scss'], ['css']);
});
gulp.task('start', function() {
return nodemon({
script: 'app.js',
watch: ['lib/', 'styles/compressed/', 'controllers/', 'data/', 'app/', 'config.yml'],
harmony_destructuring: true
});
});
gulp.task('default', gulp.series('watch'));