forked from kaklakariada/angular2-demo
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathgulpfile.js
More file actions
58 lines (51 loc) · 1.72 KB
/
Copy pathgulpfile.js
File metadata and controls
58 lines (51 loc) · 1.72 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
const gulp = require('gulp');
const del = require('del');
const typescript = require('gulp-typescript');
const sourcemaps = require('gulp-sourcemaps');
const watch = require('gulp-watch');
const batch = require('gulp-batch');
const tslint = require('gulp-tslint');
var browsersync = require('browser-sync').create();
gulp.task('serve', ['compile', 'copy:libs'], function() {
browsersync.init({
server: {
baseDir: ["./dist", "./"]
}
});
gulp.watch("dist/**/*").on('change', browsersync.reload);
gulp.watch("app/**/*.html").on('change', browsersync.reload);
gulp.watch("index.html").on('change', browsersync.reload);
gulp.watch("styles.css").on('change', browsersync.reload);
});
// clean the contents of the distribution directory
gulp.task('clean', function() {
return del('dist/**/*');
});
// TypeScript compile
gulp.task('compile', ['clean'], function() {
var tsProject = typescript.createProject('tsconfig.json');
return tsProject.src()
.pipe(sourcemaps.init())
.pipe(typescript(tsProject))
.pipe(sourcemaps.write('.'))
.pipe(gulp.dest('dist'));
});
// copy dependencies
gulp.task('copy:libs', ['clean'], function() {
return gulp.src([
'node_modules/es6-shim/es6-shim.min.js',
'node_modules/systemjs/dist/system-polyfills.js',
'node_modules/angular2/bundles/angular2-polyfills.js',
'node_modules/systemjs/dist/system.src.js',
'node_modules/rxjs/bundles/Rx.js',
'node_modules/angular2/bundles/angular2.dev.js'
])
.pipe(gulp.dest('dist/lib'));
});
gulp.task('tslint', function() {
return gulp.src('app/**/*.ts')
.pipe(tslint())
.pipe(tslint.report('verbose'));
});
gulp.task('build', ['compile', 'copy:libs', 'tslint']);
gulp.task('default', ['build']);