-
Notifications
You must be signed in to change notification settings - Fork 0
/
gulpfile.js
56 lines (48 loc) · 1.33 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
var gulp = require('gulp'),
merge = require('merge2'),
gulpWebServer = require('gulp-webserver'),
ts = require('gulp-typescript'),
sourcemaps = require('gulp-sourcemaps'),
sass = require('gulp-sass');
var src = {
ts: ['./src/**/*.ts'],
sass: ['./src/style/style.scss', './src/style/*.scss']
},
dest = {
sass: './src/style'
},
tsProject = ts.createProject('tsconfig.json');
function serve () {
return gulp.src('./')
.pipe(gulpWebServer({
livereload: true,
directoryListing: true,
open: true
}));
}
function compileTs () {
var tsResult = tsProject.src()
.pipe(sourcemaps.init())
.pipe(ts(tsProject));
return tsResult.js
.pipe(sourcemaps.write({includeContent: true}))
.pipe(gulp.dest('./'));
}
function compileSass () {
return gulp.src(src.sass)
.pipe(sourcemaps.init())
.pipe(sass().on('error', sass.logError))
.pipe(sourcemaps.write({includeContent: true}))
.pipe(gulp.dest(dest.sass));
}
function build () {
return merge([compileSass(), compileTs()]);
}
gulp.task('serve', ['build'], function () {
gulp.watch(src.ts, compileTs);
gulp.watch(src.sass, compileSass);
return serve();
});
gulp.task('build', function () {
return build();
});