-
-
Notifications
You must be signed in to change notification settings - Fork 116
/
gulpfile.js
50 lines (40 loc) · 1.38 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
import { deleteAsync } from 'del'
import gulp from 'gulp'
import pluginerror from 'plugin-error'
import browsersync from 'browser-sync'
import {spawn} from 'child_process'
const devServer = browsersync.create();
function shell(plugin, command, args) {
return (done) =>
spawn(command, args, {stdio: 'inherit'})
.on('error', (err) => {
done(new pluginerror(plugin, err))
})
.on('exit', (code) => {
if (code == 0) {
// Process completed successfully
done()
} else {
done(new pluginerror(plugin, `Process failed with exit code ${code}`));
}
})
}
function webserver(done) {
devServer.init({
watch: true,
server: "./build/dev/html/"
}, function () { this.server.on('close', done) })
};
function watch() {
gulp.watch('./source/**', gulp.series('sphinx:dev'));
};
gulp.task('clean', () => deleteAsync(['build']));
gulp.task('sphinx', shell(
'sphinx', 'sphinx-build', ['-W', '-d', 'build/doctrees', 'source', 'build/html']
));
gulp.task('sphinx:dev', shell(
'sphinx', 'sphinx-build', ['source', 'build/dev/html']
));
gulp.task('build', gulp.series('clean', 'sphinx'));
gulp.task('build:dev', gulp.series('clean', 'sphinx:dev'));
gulp.task('default', gulp.series('build:dev', gulp.parallel(webserver, watch)));