-
Notifications
You must be signed in to change notification settings - Fork 0
/
gulpfile.js
68 lines (59 loc) · 1.56 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
var gulp = require('gulp'),
jshint = require('gulp-jshint'),
uglify = require('gulp-uglify'),
notify = require('gulp-notify'),
concat = require('gulp-concat'),
rename = require('gulp-rename'),
stripDebug = require('gulp-strip-debug'),
sizereport = require('gulp-sizereport'),
browserSync = require('browser-sync').create();
// ERROR HANDLING
// ---------------
function handleError() {
this.emit('end');
}
gulp.task('browser-sync', function() {
browserSync.init({
ghostMode: {
scroll: true
},
proxy:true,
server:true,
open:false,
callbacks: {
ready: function (err, bs) {
var port = bs.options.get("port");
require("opn")("http://localhost:"+port+"/index.html");
}
}
});
});
gulp.task('build', function() {
gulp.src('src/*.js')
.pipe(concat('jquery.favico-spinner.dev.js'))
.pipe(jshint())
.pipe(jshint.reporter('default'))
.on('error', handleError)
.on('error', notify.onError())
.pipe(gulp.dest('./'))
.pipe(rename(function (path) {
path.basename = path.basename.replace('.dev','');
}))
.pipe(stripDebug())
.pipe(uglify({
mangle: {
sort: true,
toplevel:true
}
}))
.pipe(gulp.dest('./'))
.pipe(sizereport({
gzip: true
}))
.pipe(browserSync.stream({once: true}));
});
gulp.task('watch', function() {
gulp.watch(['src/**/*.js'], ['build']);
});
// Default Task
gulp.task('default', ['browser-sync','build','watch']);