-
Notifications
You must be signed in to change notification settings - Fork 0
/
gulpfile.js
62 lines (52 loc) · 1.69 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
var gulp = require('gulp');
var gutil = require('gulp-util');
var sourcemaps = require('gulp-sourcemaps');
var source = require('vinyl-source-stream');
var buffer = require('vinyl-buffer');
var watchify = require('watchify');
var browserify = require('browserify');
var compass = require('gulp-compass');
var livereload = require('gulp-livereload');
var minifyCSS = require('gulp-minify-css');
var concatCSS = require('gulp-concat-css');
var child = require('child_process');
var fs = require('fs');
// Start the default task
gulp.task('default', ['server','watch','js']);
gulp.task('server', function() {
var server = child.spawn('node', ['./bin/www']);
var log = fs.createWriteStream('server.log', { flags: 'a' });
server.stdout.pipe(log);
server.stderr.pipe(log);
});
gulp.task('watch', function() {
livereload.listen();
gulp.watch('./public/stylesheets/*.scss', ['compass']);
});
gulp.task('compass', function() {
gulp.src('./public/stylesheets/*.scss')
.pipe(compass({
css: './public/stylesheets',
sass: './public/stylesheets'
}))
.pipe(gulp.dest('./public/stylesheets'))
gulp.src('./public/stylesheets/*.css')
.pipe(concatCSS("bundle.css"))
.pipe(minifyCSS())
.pipe(gulp.dest('./dist'))
.pipe(livereload());
});
var bundler = watchify(browserify('./public/javascripts/app.js', watchify.args));
bundler.transform('brfs');
gulp.task('js', bundle)
bundler.on('update', bundle);
bundler.on('log', gutil.log);
function bundle() {
return bundler.bundle()
.on('error', gutil.log.bind(gutil, 'Browserify Error'))
.pipe(source('bundle.js'))
.pipe(buffer())
.pipe(sourcemaps.init({ loadMaps: true }))
.pipe(sourcemaps.write('./'))
.pipe(gulp.dest('./dist'));
}