-
Notifications
You must be signed in to change notification settings - Fork 0
/
Gulpfile.js
44 lines (36 loc) · 1.21 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
var gulp = require('gulp');
var sass = require('gulp-sass');
var uglify = require('gulp-uglify');
var browserify = require('browserify');
var buffer = require('vinyl-buffer');
var source = require('vinyl-source-stream');
var browserSync = require('browser-sync');
// Static Server + watching scss/html files
gulp.task('serve', ['sass'], function() {
browserSync.init({
server: "./dist"
});
// Watches for changes in JS files - hotreload
gulp.watch("./client/app.js", ['browserify']);
// Watches for changes in SCSS files - hotreload
gulp.watch("./scss/style.scss", ['sass']);
// Watches for changes in dist/html files - hotreload
gulp.watch("./dist/*.html").on('change', browserSync.reload);
});
// Compile sass into CSS & auto-inject into browsers
gulp.task('sass', function() {
return gulp.src("./scss/style.scss")
.pipe(sass())
.pipe(gulp.dest("./dist/css"))
.pipe(browserSync.stream());
});
gulp.task('browserify', function () {
return browserify('./client/app.js')
.bundle()
.pipe(source('bundle.js'))
.pipe(buffer())
.pipe(uglify())
.pipe(gulp.dest('./dist/js'))
.pipe(browserSync.stream());
});
gulp.task('default', ['serve', 'browserify']);