-
Notifications
You must be signed in to change notification settings - Fork 85
/
gulpfile.js
76 lines (67 loc) · 1.82 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
var gulp = require('gulp'),
sourcemaps = require('gulp-sourcemaps'),
typescript = require('gulp-typescript'),
webserver = require('gulp-webserver'),
tscConfig = require('./tsconfig.json'),
del = require('del'),
runSequence = require('run-sequence');
var appSrc = './dist/';
var tsProject = typescript.createProject('tsconfig.json');
gulp.task('build', function (callback) {
runSequence('clean', ['copylibs', 'copystatic', 'typescript'], callback);
});
gulp.task('clean', function () {
return del(appSrc);
});
gulp.task('copylibs', function () {
return gulp
.src([
'node_modules/systemjs/dist/system-polyfills.js',
'node_modules/systemjs/dist/system.src.js',
'node_modules/zone.js/dist/*.js',
'node_modules/core-js/**/*.js',
'node_modules/reflect-metadata/*.js',
'node_modules/rxjs/**/*.js',
'node_modules/@angular/**/*.js'
], { base: 'node_modules' })
.pipe(gulp.dest(appSrc + 'vendor'));
});
gulp.task('typescript', function () {
return gulp
.src(['src/**/*.ts'])
.pipe(sourcemaps.init())
.pipe(tsProject())
.pipe(sourcemaps.write('.'))
.pipe(gulp.dest(appSrc));
});
var staticFiles = [
'src/**/*.html',
'src/**/*.css',
'src/**/*.ico',
'src/**/*.png',
'src/**/*.svg',
'src/**/*.jpg',
'src/**/*.ttf',
'src/**/*.woff2',
'src/**/*.webapp',
'src/systemjs.config.js'
];
gulp.task('copystatic', function () {
return gulp
.src(staticFiles)
.pipe(gulp.dest(appSrc));
});
gulp.task('watch', function () {
gulp.watch('src/**/*.ts', ['typescript']);
gulp.watch(staticFiles, ['copystatic']);
});
gulp.task('webserver', function () {
gulp.src(appSrc)
.pipe(webserver({
livereload: true,
open: true
}));
});
gulp.task('default', function (callback) {
runSequence('clean', 'build', ['watch', 'webserver'], callback);
});