Repository navigation
Expand file tree
/
Copy pathgulpfile.js
More file actions
131 lines (110 loc) · 3.66 KB
/
Copy pathgulpfile.js
File metadata and controls
131 lines (110 loc) · 3.66 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
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
var gulp = require('gulp');
var ts = require('gulp-typescript');
var merge = require('merge2');
var sourcemaps = require('gulp-sourcemaps');
var runSequence = require('gulp-sequence');
var del = require('del');
var dtsBundle = require('dts-bundle');
var Builder = require('systemjs-builder');
var Q = require('q');
var watch = require('gulp-watch');
var tsd = require('gulp-tsd');
var changed = require('gulp-changed');
var tsProject = ts.createProject('tsconfig.json', { typescript: require('typescript') });
gulp.task('compile', function () {
/* Use base dir with tsconfig.json */
// var tsProject = typescript.createProject('tsconfig.json');
// return gulp.src(['./src/**/*.ts', './typings/**/*.d.ts'], { base: './src' })
// .pipe(typescript(tsProject))
// .pipe(gulp.dest('./dist'));
var tsResult = tsProject.src()
.pipe(sourcemaps.init())
.pipe(ts(tsProject));
return merge([
tsResult.dts
.pipe(gulp.dest('dist')),
tsResult.js
.pipe(sourcemaps.write())
.pipe(gulp.dest('dist'))
]);
});
gulp.task('clean', function () {
del([
'./dist'
]);
});
gulp.task('tsd', function (callback) {
tsd({
command: 'reinstall',
config: './tsd.json'
}, callback);
});
gulp.task('bundle-dts', function () {
var result = dtsBundle.bundle({
name: 'ng2-emulation',
main: 'dist/src/ng2-emulation.d.ts',
out: "~/dist/release/ng2-emulation.d.ts",
prefix: "",
verbose: false,
emitOnNoIncludedFileNotFound: true,
emitOnIncludedFileNotFound: false
});
if (!result.emitted) {
throw Error("dts-bundle from main file not emit result.");
}
});
function bundleJs() {
var builder = new Builder('dist/src');
builder.config({
meta: {
'HTML5Tokenizer.js': {
build: false
}
},
defaultJSExtensions: true
});
return builder
.bundle('ng2-emulation.js', 'dist/release/ng2-emulation-bundle.js');
}
gulp.task("bundle", function () {
var deferred = Q.defer();
bundleJs()
.then(function () {
deferred.resolve();
})
.catch(function (err) {
console.log('Build error');
console.log(err);
deferred.reject(err);
});
return deferred.promise;
});
gulp.task('default', function (done) {
runSequence('clean', 'tsd', 'compile', 'bundle', 'bundle-dts', /*"clean-temp", */done);
});
var debug_src = 'demos/ng2emulation-vs-aspnet-debug/ng2emulation-vs-aspnet-debug/TypeScript/Ng2Emulation';
var project_src = 'src';
var debug_dts = 'demos/ng2emulation-vs-aspnet-debug/ng2emulation-vs-aspnet-debug/TypeScript/typings';
var project_dts = 'typings';
gulp.task("copy-src-to-debug-env", function () {
return gulp.src(project_src + '/**/*', { base: project_src })
.pipe(gulp.dest(debug_src));
});
gulp.task("copy-changed-debug-to-src", function (){
return gulp.src(debug_src + '/**/*.ts', {base: debug_src})
.pipe(changed(project_src))
.pipe(gulp.dest(project_src));
});
gulp.task("copy-typings-to-debug-env", function () {
return gulp.src(project_dts + '/**/*', { base: project_dts })
.pipe(gulp.dest(debug_dts));
});
gulp.task("watch-debug", function () {
gulp.src(debug_src + '/**/*.ts', { base: debug_src })
.pipe(watch(debug_src, { base: debug_src }))
.pipe(gulp.dest(project_src));
});
gulp.task('start-debug-env', function (done) {
runSequence("copy-changed-debug-to-src", ['copy-src-to-debug-env', "copy-typings-to-debug-env"], "watch-debug", done);
});
//gulp.task('default', ["build"]);