-
Notifications
You must be signed in to change notification settings - Fork 0
/
gulpfile.js
73 lines (61 loc) · 1.99 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
var gulp = require('gulp');
var shell = require('gulp-shell');
var clean = require('gulp-clean');
var htmlreplace = require('gulp-html-replace');
var runSequence = require('run-sequence');
var Builder = require('systemjs-builder');
var builder = new Builder('', 'systemjs.config.js');
var bundleHash = new Date().getTime();
var mainBundleName = bundleHash + '.main.bundle.js';
var vendorBundleName = bundleHash + '.vendor.bundle.js';
var rename = require('gulp-rename');
// This is main task for production use
gulp.task('dist', function(done) {
runSequence('clean', 'compile_ts', 'bundle', 'copy_assets', 'templates', function() {
done();
});
});
gulp.task('bundle', ['bundle:vendor', 'bundle:app'], function () {
return gulp.src('index.html')
.pipe(htmlreplace({
'app': mainBundleName,
'vendor': vendorBundleName
}))
.pipe(gulp.dest('./dist'));
});
gulp.task('templates', function(){
return gulp.src('app/**/*.html')
.pipe(gulp.dest("./dist/app"))
});
gulp.task('bundle:vendor', function () {
return builder
.buildStatic('app/vendor.js', './dist/' + vendorBundleName)
.catch(function (err) {
console.log('Vendor bundle error');
console.log(err);
});
});
gulp.task('bundle:app', function () {
return builder
.buildStatic('app/main.js', './dist/' + mainBundleName)
.catch(function (err) {
console.log('App bundle error');
console.log(err);
});
});
gulp.task('compile_ts', ['clean:ts'], shell.task([
'tsc'
]));
gulp.task('copy_assets', function() {
return gulp.src(['./assets/**/*'], {base:"."})
.pipe(gulp.dest('./dist'));
});
gulp.task('clean', ['clean:ts', 'clean:dist']);
gulp.task('clean:dist', function () {
return gulp.src(['./dist'], {read: false})
.pipe(clean());
});
gulp.task('clean:ts', function () {
return gulp.src(['./app/**/*.js', './app/**/*.js.map'], {read: false})
.pipe(clean());
});