-
Notifications
You must be signed in to change notification settings - Fork 0
/
gulpfile.js
65 lines (56 loc) · 1.59 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
var gulp = require('gulp');
var connect = require('gulp-connect');
var compass = require('gulp-compass');
var minifyCSS = require('gulp-minify-css');
var gzip = require('gulp-gzip');
var source = require('vinyl-source-stream');
var browserify = require('browserify');
var babelify = require('babelify');
function swallowError(error) {
console.log(error.toString());
console.error("\u0007"); // terminal bell/beep code
this.emit('end');
}
var paths = {
sass: 'src/sass/**/*.scss',
js: [ 'src/js/**/*.js', 'src/js/**/*.jsx' ]
};
gulp.task('js', function() {
return browserify({
entries: './src/js/app.js',
paths: [ './node_modules', './public/vendor', './src/js' ],
transform: [babelify]
})
.bundle()
.on('error', swallowError)
.pipe(source('./public/js/bundle.js'))
.pipe(gulp.dest('./'));
});
gulp.task('compass', function() {
return gulp.src(paths.sass)
.pipe(compass({
css: 'public/css',
sass: 'src/sass',
}))
.on('error', swallowError)
.pipe(minifyCSS())
.pipe(gulp.dest('public/css'));
});
gulp.task('compress', ['compass', 'js'], function() {
gulp.src([ './public/**/*.js', './public/**/*.css', './public/**/*.html'])
.pipe(gzip({ gzipOptions: { level: 9 }}))
.pipe(gulp.dest('./public'));
});
gulp.task('connect', function() {
connect.server({
root: 'public/',
port: 1337,
fallback: 'public/index.html'
});
});
gulp.task('watch', function() {
gulp.watch(paths.sass, ['compass']);
gulp.watch(paths.js, ['js']);
});
gulp.task('build', ['compass', 'js', 'compress']);
gulp.task('default', ['build', 'connect', 'watch']);