-
Notifications
You must be signed in to change notification settings - Fork 0
/
gulpfile.js
48 lines (42 loc) · 1.11 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
var gulp = require('gulp');
// Requires the gulp-sass plugin
var sass = require('gulp-sass');
var sourcemaps = require('gulp-sourcemaps');
var browserSync = require('browser-sync').create();
// Gulp Dev Task
gulp.task('default', function (callback) {
runSequence(['sass','browserSync', 'watch'],
callback
)
})
// Gulp watch syntax
gulp.task('watch', ['browserSync' , 'sass'], function(){
gulp.watch('scss/**/*.scss', ['sass']);
// Reloads the browser whenever HTML or JS files change
gulp.watch('*.html', browserSync.reload);
gulp.watch('js/**/*.js', browserSync.reload);
console.log('To stop watching type control c');
})
// Convert sass to css
gulp.task('sass', function(){
return gulp.src('scss/**/*.scss')
// Initializes sourcemaps
.pipe(sourcemaps.init())
.pipe(sass({
errLogToConsole: true
}))
// Writes sourcemaps into the CSS file
.pipe(sourcemaps.write())
.pipe(gulp.dest('css'))
.pipe(browserSync.reload({
stream: true
}))
});
// Browsersync Task
gulp.task('browserSync', function() {
browserSync.init({
server: {
baseDir: ''
},
})
})