-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathgulpfile.js
More file actions
72 lines (63 loc) · 1.84 KB
/
gulpfile.js
File metadata and controls
72 lines (63 loc) · 1.84 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
const gulp = require('gulp'),
koutoSwiss = require('kouto-swiss'),
uglify = require('gulp-uglify'),
rupture = require('rupture'),
stylus = require('gulp-stylus'),
browserSync = require('browser-sync').create(),
htmlmin = require('gulp-htmlmin'),
clean = require('gulp-clean'),
runSequence = require('run-sequence'),
babelify = require('babelify'),
browserify = require('browserify'),
buffer = require('vinyl-buffer'),
source = require('vinyl-source-stream'),
reload = browserSync.reload;
gulp.task('js', function () {
var bundler = browserify({
entries: 'src/js/app.js',
debug: true
});
bundler.transform(babelify);
bundler.bundle()
.on('error', function (err) { console.error(err); })
.pipe(source('app.js'))
.pipe(buffer())
.pipe(uglify())
.pipe(gulp.dest('dist/js/'));
});
gulp.task('clean', function() {
return gulp.src('dist/')
.pipe(clean());
});
gulp.task('stylus', function() {
gulp.src('src/styl/main.styl')
.pipe(stylus({
use: [koutoSwiss(), rupture()],
compress: true
}))
.pipe(gulp.dest('dist/css/'));
});
gulp.task('htmlmin', function() {
return gulp.src('./*.html')
.pipe(htmlmin({collapseWhitespace: true}))
.pipe(gulp.dest('dist/'));
});
gulp.task('serve', function() {
browserSync.init({
server: {
baseDir: './'
}
})
})
gulp.task('images', function() {
return gulp.src('src/images/**/*')
.pipe(gulp.dest('dist/images/'));
})
gulp.task('watch', function () {
gulp.watch('src/styl/**/*.styl', ['stylus']).on('change', reload);
gulp.watch('src/js/**/*.js', ['js']).on('change', reload);
gulp.watch('*.html', ['htmlmin']).on('change', reload);
});
gulp.task('default', function(cb) {
return runSequence('clean', ['stylus', 'js', 'htmlmin', 'images', 'watch', 'serve'], cb);
});