-
Notifications
You must be signed in to change notification settings - Fork 22
/
Copy pathgulpfile.js
59 lines (50 loc) · 1.38 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
var gulp = require('gulp');
var webserver = require('gulp-webserver');
var browserify = require('browserify');
var source = require('vinyl-source-stream');
var tsify = require('tsify');
var sass = require('gulp-sass');
var paths = {
pages: ['./public/*.html', './public/**/images/**']
};
function copyHTML() {
return gulp.src(paths.pages[0])
.pipe(gulp.dest('dist/'));
}
function copyImages() {
return gulp.src(paths.pages[1])
.pipe(gulp.dest('dist/'));
}
function bundle() {
return browserify({
basedir: '.',
debug: true,
entries: ['src/main.ts'],
cache: {},
packageCache: {}
})
.plugin(tsify)
.bundle()
.pipe(source('bundle.js'))
.pipe(gulp.dest('dist/'));
}
function style() {
return gulp.src('./public/**/*.scss')
.pipe(sass())
.pipe(gulp.dest('./dist'));
}
function watch() {
gulp.watch('./src/**/*.ts', gulp.series(copyHTML, bundle));
gulp.watch('./public/**/*.html', gulp.series(copyHTML, bundle));
gulp.watch('./public/**/*.scss', style);
}
function liveReload() {
gulp.src('dist/').pipe(webserver({
livereload: true,
open: 'index.html'
}));
}
const wt = () => watch();
const live = () => liveReload();
exports.bundle = gulp.parallel(bundle, copyHTML, style, copyImages);
exports.watch = gulp.series(copyHTML, style, bundle, copyImages, gulp.parallel(wt, live));