-
Notifications
You must be signed in to change notification settings - Fork 0
/
gulpfile.js
108 lines (96 loc) · 2.15 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
'use strict';
const gulp = require('gulp');
const spawn = require('child_process').spawn;
const del = require('del');
const packageJson = require('./package.json');
const watchDelay =
(packageJson.devSettings ? packageJson.devSettings.watchDelay : undefined) ||
3000;
/**
* Cleans build
*/
gulp.task('clean', function() {
return del('build');
});
/**
* 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/**/*.{ts,js,gs,json,html}', {
base: './settings/dev/assets'
})
.pipe(gulp.dest('build/_assets'));
});
gulp.task('prodassets', function devPrep() {
return gulp
.src('./settings/prod/assets/**/*.{ts,js,gs,json,html}', {
base: './settings/prod/assets'
})
.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/**/*.{ts,js,gs,json,html}').pipe(gulp.dest('./build'));
});
/**
* Dev
*/
gulp.task(
'dev',
gulp.series('clean', 'devPrep', 'preBuild', 'devassets', 'clasp')
);
/**
* Build
*/
gulp.task(
'build',
gulp.series('clean', 'buildPrep', 'preBuild', 'prodassets', 'clasp')
);
/**
* Watcher
*/
gulp.task(
'watch',
gulp.series('dev', function watch() {
gulp.watch(
[
'./src/**/*.{ts,js,gs,json,html}',
'./settings/**/*.{ts,js,gs,json,html}'
],
{ delay: watchDelay },
gulp.series('dev')
);
})
);
/**
* Watcher
*/
gulp.task(
'watch-prod',
gulp.series('build', function watch() {
gulp.watch(
[
'./src/**/*.{ts,js,gs,json,html}',
'./settings/**/*.{ts,js,gs,json,html}'
],
{ delay: watchDelay },
gulp.series('build')
);
})
);