-
Notifications
You must be signed in to change notification settings - Fork 1
/
gulpfile.js
64 lines (49 loc) · 1.56 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
var del = require('del');
var gulp = require('gulp');
var gutil = require('gulp-util');
var uglify = require('gulp-uglify');
var minifyCSS = require('gulp-minify-css');
var concatCss = require('gulp-concat-css');
var watchify = require('watchify');
var browserify = require('browserify');
var buffer = require('vinyl-buffer');
var source = require('vinyl-source-stream');
gulp.task('clean', function() {
del(['static/css', 'static/js']);
});
gulp.task('css', function(){
gulp.src(['./node_modules/bootstrap/dist/css/*.min.css', 'dinosaurs/css/**/*.css'])
.pipe(concatCss("site.min.css"))
.pipe(minifyCSS())
.pipe(gulp.dest('./static/css/'));
gulp.src('./node_modules/bootstrap/dist/fonts/*')
.pipe(gulp.dest('./static/fonts/'));
});
gulp.task('build', ['clean', 'css'], function() {
var bundler = browserify({
entries: 'dinosaurs/index.js',
});
bundler.bundle()
.pipe(source('site.min.js'))
.pipe(buffer())
.pipe(uglify())
.pipe(gulp.dest('./static/js'));
});
gulp.task('develop', function() {
var bundler = watchify(browserify({
cache: {}, packageCache: {}, fullPaths: true,
entries: 'dinosaurs/index.js',
debug: true
}));
// bundler.transform('cssify');
bundler.on('update', rebundle);
function rebundle() {
return bundler.bundle()
// log errors if they happen
.on('error', gutil.log.bind(gutil, 'Browserify Error'))
.pipe(source('site.min.js'))
.pipe(gulp.dest('./static/js'));
}
return rebundle();
});
gulp.task('default', ['clean', 'css', 'develop']);