-
Notifications
You must be signed in to change notification settings - Fork 0
/
gulpfile.js
66 lines (51 loc) · 1.48 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
const gulp = require('gulp'),
concat = require('gulp-concat'),
rename = require('gulp-rename'),
uglify = require('gulp-uglify'),
sass = require('gulp-sass'),
ts = require('gulp-typescript')
pug = require('gulp-pug')
gls = require('gulp-live-server');
const tsProject = ts.createProject("tsconfig.json");
gulp.task('pug', ()=>{
return gulp
.src('./index.pug')
.pipe(pug())
.pipe(gulp.dest('./build'))
});
gulp.task('ts', ()=>{
return tsProject.src()
.pipe(tsProject())
.js.pipe(concat("bundle.js"))
.pipe(uglify())
.pipe(rename("bundle.min.js"))
.pipe(gulp.dest("./build/js"))
});
gulp.task('tslint', ()=>{
return gulp
.src('./ts/main.ts')
.pipe(tslint({
formatter: "verbose"
}))
.pipe(tslint.report())
})
gulp.task('sass', () => {
return gulp
.src('./sass/**/*.sass')
.pipe(sass.sync().on('error', sass.logError))
.pipe(gulp.dest('./build/css'));
});
gulp.task('server', ()=>{
const server = gls.static('./build', 8888);
server.start();
gulp.watch(['build/**/*.css', 'build/**/*.html', 'build/**/*.min.js'], (file)=>{
server.notify.apply(server, [file]);
})
})
gulp.task('watch', ()=>{
gulp.watch("ts/*.ts", ["ts"]);
gulp.watch("sass/*.sass", ["sass"]);
gulp.watch("./index.pug", ["pug"]);
});
gulp.task("run", ["sass", "ts", "pug", "server"]);
gulp.task("default", ["run", "watch"]);