-
Notifications
You must be signed in to change notification settings - Fork 4
/
gulpfile.js
48 lines (42 loc) · 1.23 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
"use strict";
// Include gulp
var fs = require("fs");
var gulp = require("gulp");
var sourcemaps = require("gulp-sourcemaps")
var path = require("path");
var browserSync = require("browser-sync").create();
var sass = require('gulp-sass');
var browserify = require("browserify");
var source = require('vinyl-source-stream');
var reload = browserSync.reload;
gulp.task('watch',['browserify', 'sass'], function(){
browserSync.init({
server:'./'
});
gulp.watch("./sass/**/*.scss", ['sass']);
gulp.watch("./scripts/**/*.js", ['browserify']);
gulp.watch("./**/*.html").on('change', reload);
gulp.watch("./bundle.js").on('change', reload);
});
gulp.task('sass',function(){
return gulp.src('./sass/**/*.scss')
.pipe(sourcemaps.init())
.pipe(sass()).on('error', function logError(error) {
console.error(error);
})
.pipe(sourcemaps.write())
.pipe(gulp.dest('./css'))
.pipe(reload({stream:true}));
});
gulp.task('browserify',function(){
return browserify(['./scripts/app.js'], {debug:true})
.bundle()
.on('error', function(err){
console.log(err);
this.emit('end');
})
.pipe(source('bundle.js'))
.pipe(gulp.dest('./'));
});
/* Default task */
gulp.task("default", ["watch"]);