-
Notifications
You must be signed in to change notification settings - Fork 1
/
gulpfile.js
97 lines (85 loc) · 1.89 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
'use strict';
const gulp = require('gulp');
const spawn = require('child_process').spawn;
const del = require('del');
/**
* Cleans build
*/
gulp.task(
'clean',
gulp.series(
function() {
return del('build');
},
function() {
return del('dist');
}
)
);
gulp.task('dist', function() {
return gulp.src('src/separators.js').pipe(gulp.dest('dist'));
});
/**
* Runs clasp
*/
gulp.task('clasp', function(cb) {
cb = cb || console.log;
const cmd = spawn('./node_modules/.bin/clasp', ['push'], {
stdio: 'inherit'
});
cmd.on('close', function(code) {
console.log('clasp exited with code ' + code);
cb(code);
});
});
gulp.task('devPrep', function devPrep() {
return gulp.src('./settings/dev/.clasp.json').pipe(gulp.dest('./'));
});
gulp.task('devassets', function devPrep() {
return gulp
.src('./settings/dev/assets/**/*.{js,gs,json,html}')
.pipe(gulp.dest('build/__dev__assets__'));
});
gulp.task('prodassets', function devPrep() {
return gulp
.src('./settings/prod/assets/**/*.{js,gs,json,html}')
.pipe(gulp.dest('build/__assets__'));
});
gulp.task('buildPrep', function buildPrep() {
return gulp.src('./settings/prod/.clasp.json').pipe(gulp.dest('./'));
});
gulp.task('preBuild', function devPrep() {
return gulp.src('./src/**/*.{js,gs,json,html}').pipe(gulp.dest('./build'));
});
/**
* Dev
*/
gulp.task(
'dev',
gulp.series('clean', 'devPrep', 'preBuild', 'devassets', 'dist', 'clasp')
);
/**
* Build
*/
gulp.task(
'build',
gulp.series('clean', 'buildPrep', 'preBuild', 'prodassets', 'dist', 'clasp')
);
/**
* Watcher
*/
gulp.task(
'watch',
gulp.series('dev', function watch() {
gulp.watch(['./src/**/*.{js,gs,json,html}'], gulp.series('dev'));
})
);
/**
* Watcher
*/
gulp.task(
'watch-prod',
gulp.series('build', function watch() {
gulp.watch(['./src/**/*.{js,gs,json,html}'], gulp.series('build'));
})
);