-
Notifications
You must be signed in to change notification settings - Fork 4
/
gulpfile.js
86 lines (70 loc) · 2.26 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
81
82
83
84
85
86
var gulp = require('gulp'),
sass = require('gulp-sass'),
concat = require('gulp-concat'),
tslint = require('gulp-tslint'),
del = require('del'),
exec = require('child_process').exec;
var sassSrc = "src/web/styles/**/*.scss",
sassDest = "src/web/styles",
sassCssSrc = "src/web/styles/scss/app.scss",
sassJsSrc = "src/web/styles/main.ts",
appSrc = "src/**/*.ts",
publicDir = "public";
var htmlSrc = 'index.html',
fontDirs = [
'jspm_packages*/github/twbs/bootstrap*/fonts/*',
'jspm_packages*/npm/font-awesome*/fonts/*'
];
var buildFiles = ['public/app*'];
gulp.task('clean', function () {
return del(buildFiles);
});
gulp.task('clean:fonts', function () {
return del(publicDir + '/' + fontDirs);
});
gulp.task('copy:fonts', function () {
return gulp.src(fontDirs)
.pipe(gulp.dest(publicDir));
});
gulp.task('compile:css', function () {
return gulp.src(sassCssSrc)
.pipe(sass())
.pipe(concat('app.css'))
.pipe(gulp.dest(sassDest));
});
gulp.task('lint:src', function () {
return gulp.src(appSrc)
.pipe(tslint())
.pipe(tslint.report({
emitError: false,
sort: true
}));
});
gulp.task('lint:src:fail', function () {
return gulp.src(appSrc)
.pipe(tslint())
.pipe(tslint.report({
sort: true
}));
});
gulp.task('build:js', gulp.series('lint:src', 'compile:css', function runBuildApp() {
return exec('npm run build-app');
}));
gulp.task('build:app', gulp.series('build:js'));
gulp.task('build', gulp.series('clean', 'copy:fonts', 'build:app'));
gulp.task('watch', gulp.series('build', function watchSources() {
return gulp.watch([sassSrc, appSrc, sassJsSrc], gulp.series('build:app')).on('change', function (event) {
console.log('Change detected: ' + event + ' was modified, running tasks...');
}).on('error', function (error) {
console.log(error);
});
}));
gulp.task('watch:dev', gulp.series('build', function watchCSS() {
return gulp.watch(sassSrc, gulp.series('compile:css')).on('change', function (event) {
console.log('Change detected: ' + event + ' was modified, running tasks...');
}).on('error', function (error) {
console.log(error);
});
}));
gulp.task('watch:build', gulp.series('build', 'watch'));
gulp.task('default', gulp.series('watch:build'));