forked from BTMorton/angular2-grid
-
Notifications
You must be signed in to change notification settings - Fork 1
/
gulpfile.js
executable file
·125 lines (107 loc) · 3.33 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
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
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
var del = require('del');
var gulp = require('gulp');
var typescript = require('gulp-typescript');
var uglify = require('gulp-uglify');
var rename = require('gulp-rename');
var symlink = require('gulp-symlink');
var sourcemaps = require('gulp-sourcemaps');
var runSequence = require('run-sequence');
var merge = require('merge2');
var KarmaServer = require('karma').Server;
var tsProject = typescript.createProject({
"target": "ES5",
"module": "commonjs",
"moduleResolution": "node",
"sourceMap": true,
"emitDecoratorMetadata": true,
"experimentalDecorators": true,
"noImplicitAny": false,
"declarationFiles": true
});
var PATHS = {
src: {
ts: ['!src/**/*.d.ts', 'src/**/*.ts'],
html: 'src/*.html',
css: 'src/*.css',
test: 'test/*.ts',
typings: 'src/**/*.d.ts'
},
typings: [
'typings/browser.d.ts',
],
testTypings: [
'typings/browser.d.ts',
'dist/*.d.ts'
],
};
gulp.task('clean', function (done) {
return del(['dist'], done);
});
gulp.task('ts', function () {
var tsResult = gulp.src(PATHS.src.ts.concat(PATHS.typings))
.pipe(sourcemaps.init())
.pipe(typescript(tsProject));
return merge([
tsResult.js.pipe(sourcemaps.write()).pipe(gulp.dest('dist')).pipe(uglify()).pipe(rename({extname: '.min.js'})).pipe(gulp.dest('dist')),
tsResult.dts.pipe(gulp.dest('src')).pipe(gulp.dest('dist'))
]);
});
gulp.task('test-clean-build', function(done) {
return del(['test/*.js'], done)
});
gulp.task('test-build', ['test-clean-build'], function () {
var tsResult = gulp.src([PATHS.src.test, PATHS.src.typings].concat(PATHS.testTypings))
.pipe(sourcemaps.init())
.pipe(typescript(tsProject));
return tsResult.js.pipe(sourcemaps.write()).pipe(gulp.dest('test'));
});
gulp.task('test', ['test-build'], function(done) {
runSequence('test-link', 'test-run', ['test-link-clean', 'test-clean-build'], done);
});
gulp.task('test-link-clean', function(done) {
return del(['rxjs'], done);
});
gulp.task('test-link', ['test-link-clean'], function() {
return gulp.src('node_modules/rxjs/').pipe(symlink('rxjs'));
});
gulp.task('test-run', function(done) {
new KarmaServer({
configFile: __dirname + '/karma.conf.js',
singleRun: true
}, done).start();
});
gulp.task('test-watch', ['test-build'], function(done) {
var karma = new KarmaServer({
configFile: __dirname + '/karma.conf.js'
}).start();
gulp.watch([PATHS.src.test], [tasks.testBuild]);
});
gulp.task('html', function () {
return gulp.src(PATHS.src.html).pipe(gulp.dest('dist'));
});
gulp.task('css', function () {
return gulp.src(PATHS.src.css).pipe(gulp.dest('dist'));
});
gulp.task('libs', function () {
return merge([
gulp.src('node_modules/').pipe(symlink('dist/node_modules')),
gulp.src('bower_components/').pipe(symlink('dist/bower_components'))
]);
});
gulp.task('clean', function(done) {
return del(['dist'], done);
});
gulp.task('build', ['clean'], function() {
return gulp.start('libs', 'html', 'css', 'ts');
});
gulp.task('rebuild', ['clean'], function() {
return gulp.start('build');
});
gulp.task('watch', ['build'], function () {
gulp.watch(PATHS.src.ts, ['ts']);
gulp.watch(PATHS.src.html, ['html']);
gulp.watch(PATHS.src.css, ['css']);
});
gulp.task('default', function() {
return gulp.start('rebuild');
});