forked from antonlegoo/gitbook-plugin-theme-gestalt
-
Notifications
You must be signed in to change notification settings - Fork 0
/
gulpfile.js
executable file
·126 lines (95 loc) · 2.66 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
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
/*
#
*/
var exec = require('child_process').exec;
var gulp = require("gulp");
var concat = require("gulp-concat");
var merge = require("merge-stream");
var rename = require("gulp-rename");
var sass = require("gulp-sass");
var browserify = require('gulp-browserify');
var bsync = require("browser-sync");
var path = require('path');
/*
## Copy over files
*/
gulp.task( "copy", function() {
// Copy over stuff
var fonts = gulp.src( ["node_modules/font-awesome/fonts/**/"] )
.pipe( gulp.dest("_assets/website/fonts/fontawesome/") )
;
var img = gulp.src( ["node_modules/gitbook-logos/output/favicon.ico"] )
.pipe( gulp.dest("_assets/website/images/") )
;
var merged = merge( fonts, img );
// merged.add(js);
return merged;
});
/*
## Build gitbook core JS
*/
gulp.task('core-js', function()
{
return gulp.src('src/js/core/index.js')
.pipe(browserify({
insertGlobals : true
}))
.pipe(rename('gitbook.js'))
.pipe(gulp.dest('./_assets/website/'))
});
/*
## Build theme JS
*/
gulp.task('theme-js', function()
{
return gulp.src('src/js/theme/index.js')
.pipe(browserify({
insertGlobals : true
}))
.pipe(rename('theme.js'))
.pipe(gulp.dest('./_assets/website/'))
});
/*
## Compile the SASS into a single CSS file
*/
gulp.task('sass', function() {
console.log( "sassing" );
// Compile
return gulp.src('./src/scss/website.scss')
.pipe( sass().on( 'error', sass.logError ) )
.pipe(rename('style.css'))
.pipe( gulp.dest( './_assets/website/' ) )
;
});
gulp.task("reload", function(done)
{
console.log("Reloading gitbook....")
exec('cd ../starter-kit/documentation/ && gitbook build', function (err, stdout, stderr)
{
console.log(stdout);
console.log(stderr);
bsync.reload();
});
done();
});
/*
## Development web server and file watcher
*/
gulp.task("server", function(done) {
bsync.init(
{
server: '../starter-kit/documentation/_book',
open: false
});
// Watch files
gulp.watch( 'src/js/core/**/*.js', gulp.series('core-js', 'reload') );
gulp.watch( 'src/js/theme/**/*.js', gulp.series('theme-js', 'reload') );
gulp.watch( 'src/**/*.scss', gulp.series('sass', 'reload') );
gulp.watch( '_layouts/**/*.html', gulp.series('reload') );
done();
});
/*
# Define main gulp tasks
*/
gulp.task("build", gulp.series( "copy", "core-js", "theme-js", "sass" ) );
gulp.task("default", gulp.series( "build", "server", "reload" ) );