-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathgulpfile.js
105 lines (91 loc) · 2.93 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
/**
* @fileoverview This is the file that determines the behavior of the Gulp task
* runner.
* @author [email protected] (Alvin Lin)
*/
var gulp = require('gulp');
var compilerPackage = require('google-closure-compiler');
var gjslint = require('gulp-gjslint');
var less = require('gulp-less');
var plumber = require('gulp-plumber');
var rename = require('gulp-rename');
var lessAutoprefix = require('less-plugin-autoprefix');
var lessCleanCss = require('less-plugin-clean-css');
var path = require('path');
var getClosureCompilerConfiguration = function(options) {
var basePath = path.dirname(__filename);
var closureCompiler = compilerPackage.gulp();
return closureCompiler({
externs: [
compilerPackage.compiler.CONTRIB_PATH + '/externs/jquery-1.9.js',
basePath + '/extern/extern.js',
basePath + '/extern/howlerjs.extern.js',
basePath + '/extern/socket.io.extern.js',
basePath + '/extern/threejs.extern.js'
],
warning_level: 'VERBOSE',
compilation_level: 'ADVANCED_OPTIMIZATIONS',
js_output_file: options.filename || 'minified.js'
});
};
var getLessConfiguration = function() {
var autoprefix = new lessAutoprefix({
browsers: ["last 2 versions"]
});
var cleanCss = new lessCleanCss({
advanced: true
});
return less({
plugins: [autoprefix, cleanCss]
});
};
gulp.task('default', ['js-lint', 'js-compile', 'less']);
gulp.task('js', ['js-lint', 'js-compile']);
gulp.task('lint', ['js-lint']);
gulp.task('js-lint', function() {
return gulp.src(['./extern/*.js',
'./lib/**/*.js',
'./public/js/**/*.js',
'./shared/*.js' ])
.pipe(gjslint({
flags: ['--jslint_error indentation',
'--jslint_error well_formed_author',
'--jslint_error braces_around_type',
'--jslint_error unused_private_members',
'--jsdoc',
'--max_line_length 80',
'--error_trace'
]
}))
.pipe(gjslint.reporter('console'));
});
gulp.task('js-compile', function() {
return gulp.src(['./public/js/**/*.js',
'./shared/*.js'])
.pipe(getClosureCompilerConfiguration({
filename: 'minified.js'
}))
.pipe(gulp.dest('./public/dist'));
});
gulp.task('less', function() {
return gulp.src('./public/less/*.less')
.pipe(getLessConfiguration())
.pipe(rename('minified.css'))
.pipe(gulp.dest('./public/dist'));
});
gulp.task('watch-js', function() {
gulp.watch(['./extern/*.js',
'./lib/**/*.js',
'./public/js/**/*.js',
'./shared/*.js' ], ['js-compile']);
});
gulp.task('watch-less', function() {
gulp.watch('./public/less/*.less', ['less']);
});
gulp.task('watch', function() {
gulp.watch(['./extern/*.js',
'./lib/**/*.js',
'./public/js/**/*.js',
'./shared/*.js' ], ['js-compile']);
gulp.watch('./public/less/*.less', ['less']);
});