-
Notifications
You must be signed in to change notification settings - Fork 0
/
gulpfile.js
65 lines (54 loc) · 1.59 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
const gulp = require("gulp")
const pug = require('gulp-pug')
const less = require('gulp-less')
const browserify = require('browserify')
const tsify = require('tsify')
const source = require('vinyl-source-stream')
const buffer = require('vinyl-buffer')
const browserSync = require('browser-sync').create();
const ts = require("gulp-typescript")
const tsProject = ts.createProject("tsconfig.json")
const sources = {
pug: 'src/*.pug',
less: 'src/less/*.less',
ts: 'src/*.ts',
tsComps: 'src/components/*ts'
}
// gulp.task("typescript", function() {
// return tsProject.src()
// .pipe(tsProject())
// .js.pipe(gulp.dest("dist"));
// });
gulp.task('less', function() {
return gulp.src(sources.less)
.pipe(less())
.pipe(gulp.dest('dist/css/'));
});
gulp.task('pug', function() {
return gulp.src(sources.pug)
.pipe(pug())
.pipe(gulp.dest('dist/'));
})
gulp.task('sync', function(done) {
browserSync.init({
server: {
baseDir: "./dist/"
},
open: false
});
done();
});
gulp.task('browserify', function() {
return browserify()
.add('./src/main.ts')
.plugin(tsify)
.bundle()
.pipe(source('bundle.js'))
.on('error', err => console.log(err))
.pipe(gulp.dest('./dist/'))
})
gulp.task('watch', function() {
console.log("watching")
gulp.watch([sources.pug, sources.less, sources.ts, sources.tsComps]).on('change', gulp.series('browserify', 'less', 'pug', browserSync.reload))
});
gulp.task('default', gulp.series( 'browserify', 'less', 'pug', 'sync', 'watch'));