-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathgulpfile.js
98 lines (91 loc) · 2.89 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
// include gulp
var gulp = require('gulp');
var env = require('./config').env;
var dev = (env == 'development')
// include plug-ins
var jshint = require('gulp-jshint');
var changed = require('gulp-changed');
var concat = require('gulp-concat');
var sourcemaps = require('gulp-sourcemaps');
var stripDebug = require('gulp-strip-debug');
var uglify = require('gulp-uglify');
var gulpFilter = require('gulp-filter'); // filter src files for specific operations
var plumber = require('gulp-plumber'); // makes sure watch doesn't break on error
var gulpif = require('gulp-if');
// JS concat, strip debugging and minify
gulp.task('incscripts', function() {
gulp.src([
'./lib/js/inc/jquery.min.js'
, './lib/js/inc/tweenmax.js'
, './lib/js/inc/jquery-ui.js'
, './lib/js/inc/jquery-form.js'
, './lib/js/inc/jquery-qtip.min.js'
, './lib/js/inc/moment.js'
, './lib/js/inc/parsley.js'
, './lib/js/inc/parsley.remote.min.js'
, './lib/js/inc/ganalytics.js'
])
.pipe(plumber({
errorHandler: function (err) {
console.log(err);
this.emit('end');
}
}))
.pipe(concat('concat.inc.js'))
.pipe(sourcemaps.write())
.pipe(stripDebug())
.pipe(uglify({mangle: false}))
.pipe(gulp.dest('./public/javascripts/'))
})
gulp.task('y2gscripts', function() {
var filter = gulpFilter(['./lib/js/infobubble.js']); // exclude infobubble from jshint
gulp.src([
'./lib/js/y2g_functions.js'
, './lib/js/map_interface.js'
, './lib/js/infobubble.js'
, './lib/js/icons.js'
, './lib/js/analytics.js'
])
.pipe(plumber({
errorHandler: function (err) {
console.log(err);
this.emit('end');
}
}))
.pipe(filter)
.pipe(jshint({laxcomma:true, asi: true, "-W041": false}))
.pipe(jshint.reporter('default'))
.pipe(filter.restore())
.pipe(concat('concat.y2g.js'))
.pipe(sourcemaps.write())
.pipe(gulpif(dev, stripDebug()))
.pipe(gulpif(dev, uglify({mangle: false})))
.pipe(gulp.dest('./public/javascripts/'))
})
gulp.task('genscripts', function() {
gulp.src([
'./lib/js/lyra.js'
, './lib/js/main.js'
, './lib/js/responsive.js'
])
.pipe(plumber({
errorHandler: function (err) {
console.log(err);
this.emit('end');
}
}))
.pipe(jshint({laxcomma:true, asi: true, "-W041": false}))
.pipe(jshint.reporter('default'))
.pipe(concat('concat.gen.js'))
.pipe(sourcemaps.write())
.pipe(gulpif(dev, stripDebug()))
.pipe(gulpif(dev, uglify({mangle: false})))
.pipe(gulp.dest('./public/javascripts/'))
})
// Watch Task
var watchList = ['incscripts', 'y2gscripts', 'genscripts']
gulp.task('watch', watchList, function () {
gulp.watch('./lib/js/**/*.js', watchList);
})
var taskList = ['watch','incscripts', 'y2gscripts', 'genscripts']
gulp.task('default', taskList);