-
Notifications
You must be signed in to change notification settings - Fork 53
/
Copy pathgulpfile.js
76 lines (66 loc) · 2.19 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
74
75
76
var gulp = require('gulp');
var less = require('gulp-less');
var path = require('path');
var mocha = require('gulp-mocha');
var browserSync = require('browser-sync');
var nodemon = require('gulp-nodemon');
var cp = require('child_process');
var tsb = require('gulp-tsb');
// compile less files from the ./styles folder
// into css files to the ./public/stylesheets folder
gulp.task('less', function() {
return gulp.src('./src/styles/**/*.less')
.pipe(less({
paths: [path.join(__dirname, 'less', 'includes')]
}))
.pipe(gulp.dest('./out/public/stylesheets'));
});
// run mocha tests in the ./tests folder
gulp.task('test', function() {
return gulp.src('./tests/out/test*.js', { read: false })
// gulp-mocha needs filepaths so you can't have any plugins before it
.pipe(mocha());
});
// run browser-sync on for client changes
gulp.task('browser-sync', ['nodemon', 'watch'], function() {
browserSync.init(null, {
open: false,
proxy: "http://localhost:3000",
files: ["out/**/*.*", "out/routes/**/*.*", "out/public/**/*.*", "out/views/**/*.*"],
port: 7000,
});
});
// run nodemon on server file changes
gulp.task('nodemon', function(cb) {
var started = false;
return nodemon({
script: 'out/www.js',
watch: ['out/**/*.js']
}).on('start', function() {
if (!started) {
cb();
started = true;
}
}).on('restart', function onRestart() {
setTimeout(function reload() {
browserSync.reload({
stream: false
});
}, 500); // browserSync reload delay
});
});
// TypeScript build for /src folder
var tsConfigSrc = tsb.create('src/tsconfig.json');
gulp.task('build', function() {
return gulp.src('./src/**/*.ts')
.pipe(tsConfigSrc())
.pipe(gulp.dest('./out'));
});
// watch for any TypeScript or LESS file changes
// if a file change is detected, run the TypeScript or LESS compile gulp tasks
gulp.task('watch', function() {
gulp.watch('src/**/*.ts', ['build']);
// gulp.watch('src/styles/**/*.less', ['less']);
});
gulp.task('buildAll', ['build', 'less']);
gulp.task('default', ['browser-sync']);