-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathgulpFile.js
77 lines (64 loc) · 2.06 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
var fs = require('fs');
var gulp = require('gulp');
var rename = require('gulp-rename');
var uglify = require('gulp-uglify');
var htmlmin = require('gulp-htmlmin');
var cssnano = require('gulp-cssnano');
var browserSync = require('browser-sync').create();
var babyparse = require('babyparse');
var _ = require('lodash');
// ****************************************************************************
// Minify CSS
gulp.task('build-css', function() {
return gulp.src('./src/css/*')
.pipe(cssnano())
.pipe(rename({ suffix: '.min'}))
.pipe(gulp.dest('./docs/css/'));
});
// Minify static HTML
gulp.task('build-html', function() {
return gulp.src('./src//index.html')
.pipe(htmlmin({collapseWhitespace: true}))
.pipe(gulp.dest('./docs/'));
});
// Minify Javascript
gulp.task('build-js', function() {
return gulp.src('./src/js/*')
.pipe(uglify())
.pipe(rename({ suffix: '.min'}))
.pipe(gulp.dest('./docs/js/'));
});
// Convert apk CSV to JSON
gulp.task('convert-csvToJson', function() {
var parseOptions = {
header: true,
dynamicTyping: true,
skipEmptyLines: true,
};
var apkJsonData = babyparse.parseFiles('./src/apkData.csv', parseOptions).data.map(function(i) {
return _.pickBy(i, _.identity);
});
// Sort by label
apkJsonData = _.sortBy(apkJsonData, function (i) {
return String(i.label).toLowerCase();
});
return fs.writeFileSync('./docs/apkData.json', JSON.stringify(apkJsonData), 'utf-8');
});
// ****************************************************************************
// DO ALL OF THE THINGZ!!!!!
gulp.task('build', ['build-html','build-js', 'build-css', 'convert-csvToJson']);
gulp.task('reload', ['build'], function(done) {
browserSync.reload();
done();
});
// Dev web Server
gulp.task('dev', ['build'], function() {
browserSync.init({
server: {
baseDir: "./docs"
},
injectChanges: false,
browser: ["chromium"]
});
gulp.watch(['./src/**/*'], ['reload']);
});