forked from TerryMooreII/angular-azure-mobile-service
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathgulpfile.js
76 lines (61 loc) · 1.68 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
// Include gulp
var gulp = require('gulp');
// Include Our Plugins
var jshint = require('gulp-jshint');
var concat = require('gulp-concat');
var uglify = require('gulp-uglify');
var rename = require('gulp-rename');
var ngmin = require('gulp-ngmin');
var SRC = 'src/angular-azure-mobile-service.js';
var MIN = 'angular-azure-mobile-service.min.js';
// Lint Task
gulp.task('lint', function() {
return gulp.src(SRC)
.pipe(jshint())
.pipe(jshint.reporter('default'));
});
// Concatenate & Minify JS
gulp.task('scripts', function() {
return gulp.src(SRC)
.pipe(ngmin({
dynamic: false
}))
.pipe(gulp.dest('dist'))
.pipe(rename(MIN))
.pipe(uglify())
.pipe(gulp.dest('dist'));
});
// Watch Files For Changes
gulp.task('watch', function() {
gulp.watch('demo/*.html', notifyLiveReload);
gulp.watch('src/*.js', notifyLiveReload)
gulp.watch('demo/css/*.css', notifyLiveReload);
});
gulp.task('express', function() {
var express = require('express');
var app = express();
app.use(require('connect-livereload')({
port: 4002
}));
app.use(express.static(__dirname));
app.listen(4000);
});
var tinylr;
gulp.task('livereload', function() {
tinylr = require('tiny-lr')();
tinylr.listen(4002);
});
function notifyLiveReload(event) {
var fileName = require('path').relative(__dirname, event.path);
tinylr.changed({
body: {
files: [fileName]
}
});
}
// Default Task
gulp.task('default', ['lint', 'scripts', 'watch']);
//Build task
gulp.task('build', ['lint', 'scripts']);
gulp.task('server', ['scripts', 'express', 'livereload', 'watch'], function() {
})