-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathgulpfile.js
More file actions
61 lines (55 loc) · 1.79 KB
/
gulpfile.js
File metadata and controls
61 lines (55 loc) · 1.79 KB
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
var gulp = require('gulp');
var connect = require('gulp-connect');
var browserify = require('browserify');
var source = require('vinyl-source-stream');
var gulp = require('gulp');
var mocha = require('gulp-mocha');
var mochaPhantomJS = require('gulp-mocha-phantomjs');
var Server = require('karma').Server;
var rename = require("gulp-rename");
var closureCompiler = require('google-closure-compiler').gulp();
gulp.task('connect', function () {
connect.server({
root: '',
port: 4000
})
});
gulp.task('build', function() {
// Grabs the app.js file
return browserify('./js/app.js')
//Bundles it and creates a file called build.js
.bundle()
.pipe(source('build.js'))
//Saves it the js/ directory
.pipe(gulp.dest('./js/'));
});
gulp.task('minify', function () {
//Minifies an existing build.js file using Google Closure compiler
return gulp.src('./js/build.js')
.pipe(closureCompiler({
compilation_level: 'SIMPLE',
language_out: 'ECMASCRIPT5',
warning_level: 'QUIET',
output_wrapper: '(function(){\n%output%\n}).call(this)',
js_output_file: 'build.min.js'
}))
.pipe(gulp.dest('./js/'));
});
gulp.task('watch', function() {
gulp.watch(['js/**/*.js', '!js/**/build.js'], { interval: 500 }, ['build'])
});
gulp.task('test', function() {
//Creates local server, runs mocha tests, then exits process (therefore killing server)
connect.server({
root: '',
port: 4000
});
return gulp.src('./test/serverTests.js').pipe(mocha())
.once('end', function () {
return new Server({
configFile: __dirname + '/karma.conf.js',
singleRun: true
}).start()
});
});
gulp.task('default', ['connect', 'watch']);