-
Notifications
You must be signed in to change notification settings - Fork 6
/
Copy pathgulpfile.js
69 lines (55 loc) · 1.7 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
var gulp = require('gulp'),
inSequence = require('run-sequence'),
del = require('del'),
inject = require('gulp-inject'),
rename = require('gulp-rename'),
concat = require('gulp-concat'),
sourcemaps = require('gulp-sourcemaps'),
typescript = require('gulp-typescript');
gulp.task('default', function (done) {
inSequence(
'clear',
[
'build-vendor',
'build-app',
'copy-app-package-file',
'copy-app-main-file'
],
'build-html'
);
});
gulp.task('clear', function (done) {
del.sync(['dist/**/*'], { force: true });
done();
});
gulp.task('copy-app-package-file', function () {
return gulp.src('src/app.package.json')
.pipe(rename('package.json'))
.pipe(gulp.dest('dist'));
});
gulp.task('copy-app-main-file', function () {
return gulp.src('src/main.js')
.pipe(gulp.dest('dist'));
});
gulp.task('build-vendor', function(){
return gulp.src([
"node_modules/systemjs/dist/system.src.js",
])
.pipe(concat('vendor.js'))
.pipe(gulp.dest('dist/js'));
});
gulp.task('build-app', function () {
var project = typescript.createProject('tsconfig.json', { sortOutput: true });
var tsResult = project.src()
.pipe(sourcemaps.init())
.pipe(typescript(project));
return tsResult.js
.pipe(sourcemaps.write())
.pipe(gulp.dest('dist/js'));
});
gulp.task('build-html', function () {
var sources = gulp.src(['dist/js/vendor.js', 'dist/js/app.js'], { read: false });
return gulp.src('src/index.html')
.pipe(inject(sources, {ignorePath: 'dist', addRootSlash: false }))
.pipe(gulp.dest('dist'));
});