-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathgulpfile.js
109 lines (92 loc) · 2.39 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
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
var gulp = require('gulp');
var browserSync = require('browser-sync').create();
var reload = browserSync.reload;
var nodemon = require('gulp-nodemon');
var clean = require('gulp-clean');
var uglify = require('gulp-uglify');
var pump = require('pump');
// Default task - stage build
gulp.task('default', ['browsersync-dev', 'watch-dev']);
//Add a task that checks that everything is installed
gulp.task('watch-dev', function () {
gulp.watch(['**.**', 'js/*','css/*'], reload);
});
// Static dev server
gulp.task('browsersync-dev', ['nodemon-dev'], function () {
browserSync.init({
proxy: "localhost:3000", // local node app address
port: 5000, // use *different* port than above
notify: true
});
//gulp.watch("*.*").on('change',function(){console.log("gulp watched")}); //reload
});
gulp.task('nodemon-dev', function (cb) {
var called = false;
return nodemon({
script: 'index.js',
ignore: [
'gulpfile.js',
'node_modules/'
]
})
.on('start', function () {
if (!called) {
called = true;
cb();
}
})
.on('restart', function () {
setTimeout(function () {
reload({ stream: false });
}, 1000);
});
});
//prod build for testing
gulp.task('test prod', ['build','browsersync-prod', 'watch-prod']);
gulp.task('watch-prod', function () {
gulp.watch(['**.**', 'js/*','css/*'], reload);
});
// Static dev server - prod build
gulp.task('browsersync-prod', ['nodemon-prod'], function () {
browserSync.init({
proxy: "localhost:3000", // local node app address
port: 5000, // use *different* port than above
notify: true
});
//gulp.watch("*.*").on('change',function(){console.log("gulp watched")}); //reload
});
gulp.task('nodemon-prod', function (cb) {
var called = false;
return nodemon({
script: 'index.js',
ignore: [
'gulpfile.js',
'node_modules/'
]
})
.on('start', function () {
if (!called) {
called = true;
cb();
}
})
.on('restart', function () {
setTimeout(function () {
reload({ stream: false });
}, 1000);
});
});
//Build Prod
gulp.task( 'build', ['compress'], function() {
console.log("Prod build complete.")
});
gulp.task('compress', function () {
pump([
gulp.src('js/*.js'),
uglify(),
gulp.dest('dist/js')
],
console.log("Compress complete...")
);
});
//test prod