-
Notifications
You must be signed in to change notification settings - Fork 3
/
Copy pathgulpfile.js
73 lines (60 loc) · 1.87 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
var gulp = require('gulp');
var connect = require('gulp-connect');
var ts = require('gulp-typescript');
var nodemon = require('gulp-nodemon')
var install = require("gulp-install");
var gulpsync = require('gulp-sync')(gulp);
// !!! Should get all files but not from project file
var tsProject = ts.createProject('client/scripts/tsconfig.json');
gulp.task('angular', function() {
// place code for your default task here
return gulp.src(['node_modules/angular2/**/*']).pipe(gulp.dest('client/bower_components/angular2'));
});
gulp.task('connect', function() {
connect.server({
root: 'client',
livereload: {
enabled: true,
port: 35729
},
fallback: 'client/index.html'
});
});
gulp.task('watch', function () {
gulp.watch(['client/scripts/**/*.js', 'client/styles/**/*.css', 'client/views/**/*.html', 'client/scripts/**/*.html', 'client/*.html']).on('change', function (file) {
console.log('reload');
gulp.src(file.path).pipe( connect.reload() );
});
gulp.watch(['client/scripts/**/*.ts'], ['typescript']);
});
gulp.task('typescript', function () {
var tsResult = tsProject.src('client/scripts/**/*.ts')
.pipe(ts(tsProject));
return tsResult.js.pipe(gulp.dest('client/scripts/'));
});
gulp.task('server', function () {
nodemon({
script: 'server/server.js'
, ext: 'js html json'
, env: { 'NODE_ENV': 'development' }
, watch: [
'server/**'
]
})
})
gulp.task('install', function () {
gulp.src(['./client/bower.json', './package.json'])
.pipe(install());
})
// !!! Clean js files before compiling or create new clean js task
// run angular task only if angular folder in bower is empty
gulp.task('client', gulpsync.sync(
[
'install',
'angular',
'typescript',
[
'connect', 'watch', 'server'
]
]
));