-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathgulpfile.js
More file actions
103 lines (86 loc) · 3.55 KB
/
Copy pathgulpfile.js
File metadata and controls
103 lines (86 loc) · 3.55 KB
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
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
var gulp = require('gulp');
var inject = require('gulp-inject');
var concat = require('gulp-concat');
var print = require('gulp-print');
var angularFilesort = require('gulp-angular-filesort');
var uglify = require('gulp-uglify');
var del = require('del');
var ts = require('gulp-typescript');
gulp.task('build', ['spa-task'], function() {
});
gulp.task('clean-build', function() {
return del(['.build'], {force: true}).then(paths =>
console.log('Deleted files and folders:\n', paths.join('\n')));
});
gulp.task('copy-posts-html', ['clean-build'], function() {
var target = gulp.src('./src/posts/*.html');
return target.pipe(gulp.dest('.build/posts/'));
});
gulp.task('copy-index-html', ['clean-build'], function() {
var target = gulp.src('./views/index.html');
return target.pipe(gulp.dest('.build/'));
});
gulp.task('copy-html', ['copy-posts-html', 'copy-index-html'], function() {
});
gulp.task('css-task', ['copy-html'], function () {
var target = gulp.src('.build/index.html');
var customCssStream = gulp.src(['./bower_components/bootstrap/dist/css/bootstrap.min.css',
'./styles/site.css']);
return target
.pipe(inject(
customCssStream.pipe(print())
.pipe(concat('appStyles.css'))
.pipe(gulp.dest('.build/css')), { name: 'styles' })
)
.pipe(gulp.dest('.build/'));
});
gulp.task('vendors-task', ['css-task'], function () {
var target = gulp.src('.build/index.html');
var vendorStream = gulp.src(['./bower_components/angular-route/angular-route.js',
'./bower_components/angular/angular.js',
'./bower_components/bootstrap/dist/js/bootstrap.js',
'./bower_components/jquery/dist/jquery.js']);
return target
.pipe(inject(
vendorStream.pipe(print())
.pipe(angularFilesort())
.pipe(concat('vendors.js'))
.pipe(gulp.dest('.build/vendors')), { name: 'vendors' }))
.pipe(gulp.dest('.build/'));
});
gulp.task('ts-compile-domain', ['clean-build'], function() {
var domainTsResult = gulp.src('./src/domain/*.ts');
return domainTsResult
.pipe(ts({
out: 'domain.js'
}))
.pipe(gulp.dest('.build/src-js/'));
});
gulp.task('ts-compile-app', ['clean-build'], function() {
var appTsResult = gulp.src(['./src/app.ts', './src/common/services/*.ts', './src/posts/*.ts']);
return appTsResult
.pipe(ts({
out: 'app.js'
}))
.pipe(gulp.dest('.build/src-js/'));
});
gulp.task('ts-compile', ['ts-compile-domain', 'ts-compile-app'], function() {
});
gulp.task('spa-task', ['ts-compile', 'vendors-task'], function () {
var target = gulp.src('.build/index.html');
var appDomainStream = gulp.src('.build/src-js/domain.js');
var appStream = gulp.src('.build/src-js/app.js');
return target
.pipe(inject(appDomainStream
.pipe(print())
.pipe(concat('domain.js'))
.pipe(uglify())
.pipe(gulp.dest('.build/spa')), { name: 'domain' }))
.pipe(gulp.dest('.build/'))
.pipe(inject(appStream
.pipe(print())
.pipe(concat('app.js'))
.pipe(uglify())
.pipe(gulp.dest('.build/spa')), { name: 'app' }))
.pipe(gulp.dest('.build/'))
});