This repository has been archived by the owner on Apr 19, 2018. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathgulpfile.js
69 lines (59 loc) · 2.34 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'),
changed = require('gulp-changed'),
ts = require('gulp-typescript'),
del = require('del'),
path = require('path'),
using = require('gulp-using'),
exec = require('child_process').exec;
sourcemaps = require('gulp-sourcemaps');
var tsProject = ts.createProject("src/tsconfig.json");
gulp.task('transpile', function () {
var tsResult = gulp.src('src/**/*.ts')
.pipe(changed('public', { extension: '.js' }))
.pipe(using({prefix:'Transpiling file', path:'cwd', color:'green', filesize:false}))
.pipe(sourcemaps.init())
// .pipe(tsProject());
// .pipe(tsProject(ts.reporter.defaultReporter()));
// .pipe(tsProject(ts.reporter.fullReporter(true)));
.pipe(tsProject(ts.reporter.longReporter()));
// attribute sourceRoot not needed, because sourcemaps writes the
// complete source code into map file (in attribute sourcesContent)
var result = tsResult.js
//.pipe(sourcemaps.write('./', { sourceRoot: 'src' } ))
.pipe(sourcemaps.write('./'))
.pipe(gulp.dest('public'));
return result;
});
gulp.task('clean', function () {
console.log('deleting public/ng2 and public/html');
return del(['public/ng2', 'public/html']);
});
gulp.task('start', [ 'build' ], function (cb) {
exec('node public/js/main.js', function (err, stdout, stderr) {
console.log(stdout);
console.log(stderr);
cb(err);
});
});
gulp.task('copyHtml', function () {
gulp
.src('src/ng2/**/*.html')
.pipe(changed('public/html', { extension: '.html' }))
.pipe(using({prefix:'Copying file', path:'cwd', color:'blue', filesize:false}))
.pipe(gulp.dest('public/html/'));
});
gulp.task('copyCss', function () {
gulp
.src('src/ng2/**/*.css')
.pipe(changed('public/css', { extension: '.css' }))
.pipe(using({prefix:'Copying file', path:'cwd', color:'blue', filesize:false}))
.pipe(gulp.dest('public/css/'));
});
gulp.task('cleanAndBuild', [ 'clean' ], function () {
gulp.start('build');
});
gulp.task('build', ['copyHtml', 'copyCss', 'transpile'], function () {
console.log(' ... build results written to ' + path.join(__dirname, '/public/ng2'));
});
gulp.task('run', ['build']);
gulp.task('default', ['run']);