-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathgulpfile.js
58 lines (49 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
var gulp = require('gulp'),
del = require('del'),
sourcemaps = require('gulp-sourcemaps'),
jsuglify = require('gulp-uglify'),
typescript = require('gulp-typescript'),
tslint = require('gulp-tslint'),
tsProject = typescript.createProject('tsconfig.json'),
concatCss = require('gulp-concat-css');
var appDev = 'dev/',
appProd = 'app/',
appView = 'view/',
appStyles = 'style/'
// Tasks
gulp.task('tslint', function() {
return gulp.src(appDev + '**/*.ts')
.pipe(tslint())
.pipe(tslint.report("verbose"));
});
gulp.task('clean-app', function() {
return del(appProd + '**/*');
});
gulp.task('clean-view', function() {
return del(appView + '**/*');
});
// TypeScript compile
gulp.task('build-ts', ['clean-app', 'tslint'], function() {
return gulp
.src(appDev + '**/*.ts')
.pipe(sourcemaps.init()) // <--- sourcemaps
.pipe(typescript(tsProject))
.pipe(sourcemaps.write('.')) // <--- sourcemaps
.pipe(gulp.dest(appProd));
});
// HTML and CSS
gulp.task('build-html', ['clean-view'], function() {
return gulp.src(appDev + '**/*.html')
.pipe(gulp.dest(appView));
});
gulp.task('build-css', function() {
return gulp.src(appDev + '**/*.css')
.pipe(concatCss('style.min.css'))
.pipe(gulp.dest(appStyles));
});
gulp.task('watch', function() {
gulp.watch(appDev + '**/*.ts', ['build-ts']);
gulp.watch(appDev + '**/*.html', ['build-html']);
gulp.watch(appDev + '**/*.css', ['build-css']);
});
gulp.task('default', ['watch', 'build-ts', 'build-html', 'build-css']);