-
Notifications
You must be signed in to change notification settings - Fork 0
/
gulpfile.js
59 lines (53 loc) · 1.41 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
const gulp = require('gulp');
const gutil = require('gulp-util');
const sass = require('gulp-sass');
const browserSync = require('browser-sync').create();
const reload = browserSync.reload;
const autoprefixer = require('gulp-autoprefixer');
const cssbeautify = require('gulp-cssbeautify');
const nodemon = require('gulp-nodemon');
gulp.task('sass', function () {
gulp.src('./public/stylesheets/sass/app.sass')
.pipe(sass())
.pipe(autoprefixer({
browsers: ['last 2 versions'],
cascade: false
}))
.pipe(cssbeautify({
indent: ' ',
autosemicolon: true
}))
.pipe(gulp.dest('./public/stylesheets/css'))
.pipe(reload({stream: true}))
.on('error', gutil.log);
});
gulp.task('nodemon', function(done){
let running = false;
return nodemon({
script: './bin/www',
exec: 'babel-node --presets es2015',
ext: 'js pug',
}).on('start', function() {
if (!running) {
done();
}
running = true;
}).on('restart', function() {
setTimeout(function() {
reload();
}, 500);
});
});
gulp.task('browser-sync', ['nodemon'], function() {
browserSync.init(null, {
proxy: 'http://localhost:3000/',
port: 4000,
notify: false
});
});
gulp.task('serve', ['browser-sync'], function() {
gulp.watch('./public/stylesheets/sass/**/*.*', ['sass']);
gulp.watch('./public/stylesheets/css/**/*.*').on('change', reload);
gulp.watch('./public/javascripts/**/*.*').on('change', reload);
});
gulp.task('default', ['sass', 'serve']);