-
-
Notifications
You must be signed in to change notification settings - Fork 16
/
Copy pathgulpfile.js
80 lines (70 loc) · 2.09 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
var gulp = require("gulp");
var ts = require("gulp-typescript");
var tsProject = ts.createProject("tsconfig.json");
var sourcemaps = require('gulp-sourcemaps');
var nodemon = require('gulp-nodemon');
var watch = require('gulp-watch');
var paths = {
pages: ['src/*.html'],
src: 'src',
dist: 'dist'
};
function copyHtml() {
gulp.src('src/icons/*.png', { base: paths.src })
.pipe(gulp.dest(paths.dist))
return gulp.src(paths.pages, { base: paths.src })
.pipe(gulp.dest(paths.dist));
}
gulp.task("copy-html", copyHtml);
gulp.task('develop', function (done) {
var stream = nodemon({
legacyWatch: true,
exec: 'node --inspect=9229 --preserve-symlinks --experimental-modules --trace-warnings /usr/lib/node_modules/node-red/red.js',
ext: '*.js',
watch: [paths.dist],
ignore: ["*.map"],
done: done,
verbose: true,
delay: 10000,
env: { "NO_UPDATE_NOTIFIER": "1" }
});
copyHtml();
tsProject.src()
.pipe(sourcemaps.init())
.pipe(tsProject())
.js
.pipe(sourcemaps.write('.'))
.pipe(gulp.dest(paths.dist));
watch(paths.pages).on('change', () => {
copyHtml();
stream.emit('restart', 10000)
});
watch('src/*.ts').on('change', () => {
tsProject.src()
.pipe(sourcemaps.init())
.pipe(tsProject())
.js
.pipe(sourcemaps.write('.'))
.pipe(gulp.dest(paths.dist));
stream.emit('restart', 10000)
});
stream
.on('restart', function () {
console.log('restarted!')
})
.on('crash', function () {
console.error('Application has crashed!\n')
stream.emit('restart', 10000) // restart the server in 10 seconds
})
})
gulp.task("default", gulp.series(
gulp.parallel('copy-html'),
() => {
return tsProject.src()
.pipe(sourcemaps.init())
.pipe(tsProject())
.js
.pipe(sourcemaps.write('.'))
.pipe(gulp.dest(paths.dist));
})
);