-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathgulpfile.js
More file actions
84 lines (70 loc) · 2.51 KB
/
gulpfile.js
File metadata and controls
84 lines (70 loc) · 2.51 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
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
var gulp = require("gulp");
var concat = require('gulp-concat');
//var htmlReplace = require('gulp-html-replace');
var browserify = require('browserify');
var browserifyData = require('browserify-data');
var source = require('vinyl-source-stream');
var uglify = require('gulp-uglify');
var envify = require('envify/custom');
var buffer = require('vinyl-buffer');
var spawn = require('child_process').spawn,
gutil = require('gulp-util');
var mocha = require('gulp-mocha');
gulp.task('mocha', function() {
return gulp.src('test/filtrate.js', {read: false})
// gulp-mocha needs filepaths so you can't have any plugins before it
.pipe(mocha({reporter: 'nyan'}));
});
gulp.task('casper', function () {
var tests = ['test/test_it_loads.js'];
var casperChild = spawn('node_modules/.bin/casperjs', ['test'].concat(tests), {'stdio': 'inherit'});
casperChild.on('close', function (code) {
var success = code === 0; // Will be 1 in the event of failure
// Do something with success here
});
});
gulp.task('browserify', function() {
return browserify()
.transform(envify())
.transform(envify({'_': 'purge'}))
.transform(browserifyData)
.add('./app/index.js')
.bundle()
//Pass desired output filename to vinyl-source-stream
.pipe(source('index.js'))
.pipe(buffer())
// Start piping stream to tasks!
.pipe(gulp.dest('build'));
});
gulp.task('browserifyFixPos', function() {
return browserify()
.transform(browserifyData)
.add('./app/fixPos.js')
.bundle()
//Pass desired output filename to vinyl-source-stream
.pipe(source('fixPos.js'))
.pipe(buffer())
// Start piping stream to tasks!
.pipe(gulp.dest('build'));
});
gulp.task('copyHtml', function(){
return gulp.src('app/*.html')
.pipe(gulp.dest('build'));
});
gulp.task('watch', function(){
gulp.watch(['app/index.js', 'app/js/*'], ['browserify']);
gulp.watch(['app/fixPos.js', 'app/js/*'], ['browserifyFixPos']);
gulp.watch(['app/*.html'], ['copyHtml']);
});
gulp.task('distJs', ['browserify'], function(){
return gulp.src('build/index.js')
.pipe(uglify())
.pipe(gulp.dest('dist'));
});
gulp.task('distHtml', ['copyHtml'], function() {
return gulp.src('build/index.html')
.pipe(gulp.dest('dist'));
});
gulp.task('dist', ['distJs', 'distHtml']);
gulp.task('default', ['browserify', 'copyHtml', 'browserifyFixPos']);
gulp.task('test', ['casper', 'mocha']);