This repository has been archived by the owner on Feb 13, 2021. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 188
/
Gruntfile.js
226 lines (215 loc) · 7.54 KB
/
Gruntfile.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
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
module.exports = function(grunt) {
// show elapsed time at the end
require('time-grunt')(grunt);
// load all grunt tasks
require('load-grunt-tasks')(grunt);
var serveStatic = require('serve-static');
grunt.loadNpmTasks('@vamship/grunt-typedoc');
grunt.loadNpmTasks('grunt-contrib-connect');
grunt.loadNpmTasks('grunt-contrib-copy');
grunt.loadNpmTasks('grunt-http-download');
const sass = require('node-sass');
grunt.initConfig({
// TODO use https://www.npmjs.com/package/grunt-newer to only process updated files
watch: {
sources: {
files: ['content/**/*.md', 'data/statics.json'],
//files : ['views/**/*.pug', 'content/**/*.md', 'data/statics.json'],
//recompiles everything but doesn't reindex the search
tasks: [
'execute:compileIndex',
'execute:compileExamples',
'execute:compileWhatsNew',
'execute:compileHtmlStatics'
],
//As a very heavy task, put a little debounce of two seconds
options: {
//debounceDelay: 2000
interval: 5007,
interrupt: true,
livereload: true
}
},
typedoc: {
files: './typedoc/babylon.d.ts',
tasks: ['typedoc:build'],
}
},
connect: {
server: {
options: {
port: 8080,
base: 'public/html',
livereload: true,
hostname: 'localhost',
middleware: function(connect, options) {
var middlewares = [];
middlewares.push(function(req, res) {
//console.log(req);
});
var middlewares = [];
if (!Array.isArray(options.base)) {
options.base = [options.base];
}
var directory = options.directory || options.base[options.base.length - 1];
options.base.forEach(function(base) {
// Serve static files. (use serve-static instead)
middlewares.push(serveStatic(base));
});
// not found? do the html magic!
middlewares.push(function(req, res, next) {
for (var file, i = 0; i < options.base.length; i++) {
file = options.base/* './public/html'*/ + req.url + ".html";
if (grunt.file.exists(file)) {
require('fs').createReadStream(file).pipe(res);
return;
}
}
//not found ?
res.statusCode = 404;
res.end(req.url + ' not found');
});
return middlewares;
}
}
}
},
// Open Config
open: {
local: {
path: 'http://localhost:8080'
}
},
// Sass Config
sass: {
dist: { // Target
options: {
implementation: sass,
sourceMap: false,
outputStyle: "compressed"
},
files: {
'./public/html/css/main.css': './public/scss/main.scss',
}
}
},
download: {
documentation: {
src: 'https://raw.githubusercontent.com/BabylonJS/Babylon.js/master/dist/preview%20release/documentation.d.ts',
dest: './typedoc/babylon.d.ts'
}
},
typedoc: {
build: {
options: {
target: 'es2015',
out: './public/html/api',
name: 'Babylon.js classes documentation',
excludeExternals: true,
excludePrivate: true,
excludeProtected: true,
includeDeclarations: true,
entryPoint: `BABYLON`,
mode: "file",
theme: './typedoc/default'
},
src: './typedoc/babylon.d.ts'
}
},
clean: {
json: {
options: {
force: true
},
src: [
'data/**.json',
'!data/static-tags.json',
'!data/statics.json',
'public/html/**/*.html',
'!public/html',
'!public/html/api/**/*.*'
]
},
tmp: {
options: {
force: true
},
src: [
'.tmp/**/*'
]
}
},
execute: {
compileIndex: {
options: {
module: true
},
src: ['./scripts/compile-html/compile-html-index.js']
},
compileExamples: {
call: function(grunt, options, async) {
require('./scripts/compile-html/compile-html-examples')(async());
}
},
compileWhatsNew: {
options: {
module: true
},
src: ['./scripts/compile-html/compile-html-whats-new.js']
},
compileHtmlStatics: {
call: function(grunt, options, async) {
require('./scripts/compile-html/compile-html-statics')(async());
}
},
indexer: {
call: function(grunt, options, async) {
require('./scripts/helpers/indexer/azure')(async());
}
},
remoteIndexCleanup: {
call: function(grunt, options, async) {
require('./scripts/helpers/indexer/azureCleanup')(async());
}
}
},
copy: {
exampleIcons: {
files: [
// includes files within path and its sub-directories
{
expand: true,
src: ['./examples/icons/**'],
dest: './public/html/'
}
],
},
}
});
grunt.registerTask('serve', 'Start working', [
//'build',
'connect:server',
'open:local',
'watch'
]);
grunt.registerTask('build', 'Build content and index it', [
'clean:json',
'download:documentation',
'typedoc:build',
'execute:compileIndex',
'execute:compileExamples',
'copy:exampleIcons',
'execute:compileWhatsNew',
'execute:compileHtmlStatics',
'execute:indexer',
'execute:remoteIndexCleanup',
'clean:tmp'
]);
grunt.registerTask('examples', 'Build examples page', [
'execute:compileExamples',
'copy:exampleIcons'
]);
grunt.registerTask('buildCss', 'Compile SCSS into CSS', [
'sass'
]);
};