1 | const { src, dest, watch, series } = require('gulp');
|
2 | const del = require('del');
|
3 | const ts = require('gulp-typescript');
|
4 | const tsProject = ts.createProject('tsconfig.json');
|
5 | const tsConfig = require('./tsconfig.json');
|
6 |
|
7 | function clean() {
|
8 | return del('index.js');
|
9 | }
|
10 |
|
11 | function tsc() {
|
12 | return tsProject.src()
|
13 | .pipe(tsProject())
|
14 | .pipe(dest('.'));
|
15 | }
|
16 |
|
17 | function server(cb) {
|
18 | const hawtioBackend = require('./index.js');
|
19 | hawtioBackend.setConfig({
|
20 | logLevel: require('js-logger').DEBUG,
|
21 | port: 8080,
|
22 | staticProxies: [{
|
23 | port: 8282,
|
24 | path: '/hawtio/jolokia',
|
25 | targetPath: '/hawtio/jolokia'
|
26 | }],
|
27 | liveReload: {
|
28 | enabled: true
|
29 | }
|
30 | });
|
31 | hawtioBackend.listen(function(server) {
|
32 | const host = server.address().address;
|
33 | const port = server.address().port;
|
34 | console.log("started from gulp file at ", host, ":", port);
|
35 | cb();
|
36 | });
|
37 | }
|
38 |
|
39 | function watcher() {
|
40 | return watch([...tsConfig.include, 'assets/*'], () => src('.').pipe(hawtioBackend.reload()));
|
41 | }
|
42 |
|
43 | exports.build = series(clean, tsc);
|
44 | exports.default = series(clean, tsc, server, watcher);
|