-
Notifications
You must be signed in to change notification settings - Fork 2
/
gulpfile.js
40 lines (35 loc) · 1.05 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
const gulp = require('gulp');
const util = require('gulp-util')
const gulpConnect = require('gulp-connect');
const connect = require('connect');
const cors = require('cors');
const path = require('path');
const exec = require('child_process').exec;
const portfinder = require('portfinder');
const DIST_DIR = 'web_deploy';
gulp.task('build', function (cb) {
exec('npm run build', function (err, stdout, stderr) {
console.log(stderr);
cb(err);
});
});
gulp.task('reload', gulp.series('build'), function () {
gulp.src(DIST_DIR).pipe(gulpConnect.reload())
});
gulp.task('watch', function () {
gulp.watch([process.env.API_SPEC_DIR_FILE || '.', 'spec/**/*', 'web/**/*'], gulp.series('reload'));
});
gulp.task('serve', gulp.parallel('build', 'watch', function() {
portfinder.getPort({ port: process.env.PORT_REDOC || 5000 }, function (err, port) {
gulpConnect.server({
root: [DIST_DIR],
livereload: true,
port: port,
middleware: function (gulpConnect, opt) {
return [
cors()
]
}
});
});
}));