-
Notifications
You must be signed in to change notification settings - Fork 0
/
gulpfile.js
53 lines (41 loc) · 1.4 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
var gulp = require('gulp'),
livereload = require('gulp-livereload'),
sass = require('gulp-sass');
var PATHS = {
toWatch: ['components/**/*.*','src/**/*.ts','src/**/*.scss','index.html']
}
gulp.task('clean', function (done) {
var del = require('del');
del(['dist'], done);
});
gulp.task('sass', function(){
return gulp.src('./src/**/*.scss')
.pipe(sass().on('error', sass.logError))
.pipe(gulp.dest('./css'))
.pipe(livereload());
})
gulp.task('ts2js', function () {
var typescript = require('gulp-typescript');
var tscConfig = require('./tsconfig.json');
var tsResult = gulp
.src(['src/**/*.ts', 'node_modules/angular2/typings/browser.d.ts'])
.pipe(typescript(tscConfig.compilerOptions));
return tsResult
.js
.pipe(gulp.dest('./dist'))
.pipe(livereload());
});
gulp.task('play', ['ts2js'], function () {
var server = livereload.listen({ basePath: 'dist' });
var http = require('http');
var connect = require('connect');
var serveStatic = require('serve-static');
var open = require('open');
var port = 9000, app;
gulp.watch(PATHS.toWatch, ['ts2js', 'sass']);
app = connect().use(serveStatic(__dirname));
http.createServer(app).listen(port, function () {
open('http://localhost:' + port);
});
});
gulp.task('default', ['play']);