-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathgulpfile.js
50 lines (44 loc) · 1.29 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
var gulp = require('gulp');
var sass = require('gulp-sass');
var browserSync = require('browser-sync').create();
var runSequence = require('run-sequence');
var autoprefixer = require('gulp-autoprefixer');
var postcss = require('gulp-postcss');
var pxtorem = require('postcss-pxtorem');
gulp.task('watch', ['browserSync', 'sass'], function(){
// Run sass compilation task whenever SASS files change
gulp.watch('app/scss/*.scss', ['sass']);
// Reloads the browser whenever HTML or JS files change
gulp.watch('app/*.html', browserSync.reload);
});
// Converts Sass to CSS and prefix
gulp.task('sass', function(){
var processors = [
pxtorem({
replace: false,
propWhiteList: []
})
];
return gulp.src('app/scss/main.scss')
.pipe(sass())
.pipe(autoprefixer())
.pipe(postcss(processors))
.pipe(gulp.dest('app/css'))
.pipe(browserSync.reload({
stream: true
}))
});
// Hot reload
gulp.task('browserSync', function() {
browserSync.init({
server: {
baseDir: 'app'
},
})
});
/* Default task which compiles sass and html includes, run hot reload and watch for changes */
gulp.task('default', function (callback) {
runSequence(['sass','browserSync', 'watch'],
callback
)
});