-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathgulpfile.js
More file actions
106 lines (87 loc) · 3.98 KB
/
gulpfile.js
File metadata and controls
106 lines (87 loc) · 3.98 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
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
var gulp = require('gulp')
var gutil = require('gulp-util')
var glob = require('glob')
var exec = require('child_process').exec
var sass = require('gulp-sass')
var browserify = require('browserify')
var debowerify = require('debowerify')
var source = require('vinyl-source-stream')
var through = require('through')
gulp.task('test', [ 'test:units', 'test:features' ])
gulp.task('test:units', function() {
exec('NODE_ENV=test mocha test/units/ --colors --recursive --compilers coffee:coffee-script/register --reporter spec', function(e, stdout, stderr) {
console.log(stdout, stderr)
})
})
gulp.task('test:features', function() {
exec('NODE_ENV=test mocha test/features/ --colors --recursive --compilers coffee:coffee-script/register --reporter spec', function(e, stdout, stderr) {
console.log(stdout, stderr)
})
})
gulp.task('buildCSS', function () {
gulp.src([ './app/boot.scss' ])
.pipe(sass())
.pipe(gulp.dest('./public/css'))
});
gulp.task('buildHTML', function() {
gulp.src([ './app/**/*.html', skipMatcher ])
.pipe(gulp.dest('./public'))
})
gulp.task('buildJS', function() {
glob('./app/**/*.req.js', function(e, widgets) {
browserify('./app/boot.js')
// use lodash instead of underscore
.transform(function() {
var data = ''
var widgetRequires = widgets
.map(function(widget) {
return "require('" + widget.replace('/app', '') + "');"
}).join('')
return through(function(b) { data += b }, function() {
var replaced = data
.replace(/underscore/g, 'lodash')
.replace('// require all widgets', widgetRequires)
this.queue(replaced)
this.queue(null)
})
})
// search for modules in public/bower_components
.transform(debowerify)
// returns read stream
.bundle({ debug: true })
// turns browserify stream into stream that return vinyl file object... weird, but whatever
.pipe(source('boot.js'))
// put to file!!
.pipe(gulp.dest('./public/js'))
})
})
var skipMatcher = '!./app/{bower_components,bower_components/**}'
gulp.task('watch', function() {
gulp.watch([ './app/**/*.js', skipMatcher], [ 'buildJS' ])
gulp.watch([ './app/**/*.scss', skipMatcher], [ 'buildCSS' ])
gulp.watch([ './app/**/*.html', skipMatcher], [ 'buildHTML' ])
})
gulp.task('server', function() {
exec('static public', console.log)
})
gulp.task('dev', [ 'server', 'watch' ])
//==========================================================================//
// This file is part of multi-site-client-poc. //
// //
// multi-site-client-poc is Copyright 2014 Volary Foundation and //
// Contributors //
// //
// multi-site-client-poc is free software: you can redistribute it and/or //
// modify it under the terms of the GNU Affero General Public License as //
// published by the Free Software Foundation, either version 3 of the //
// License, or at your option) any later version. //
// //
// multi-site-client-poc is distributed in the hope that it will be useful, //
// but WITHOUT ANY WARRANTY; without even the implied warranty of //
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Affero //
// General Public License for more details. //
// //
// You should have received a copy of the GNU Affero General Public //
// License along with multi-site-client-poc. If not, see //
// <http://www.gnu.org/licenses/>. //
//==========================================================================//