-
Notifications
You must be signed in to change notification settings - Fork 1
/
gulpfile.js
57 lines (49 loc) · 1.43 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
/* global require */
const gulp = require('gulp');
const browserSync = require('browser-sync').create();
const sass = require('gulp-sass');
const prefix = require('gulp-autoprefixer');
const path = require('path');
/* Change your directory and settings here */
const settings = {
publicDir: '.',
sassDir: 'scss',
cssDir: 'assets/css'
};
/**
* serve task, will launch browserSync and launch index.html files,
* and watch the changes for html and sass files.
**/
gulp.task('serve', ['sass'], function() {
/**
* Launch BrowserSync from publicDir
*/
browserSync.init({
server: settings.publicDir
});
/**
* watch for changes in sass files
*/
gulp.watch(settings.sassDir + "/**/*.scss", ['sass']);
/**
* watch for changes in html files
*/
gulp.watch(settings.publicDir + "/*.html").on('change', browserSync.reload);
});
/**
* sass task, will compile the .SCSS files,
* and handle the error through plumber and notify through system message.
*/
gulp.task('sass', function() {
return gulp.src(settings.sassDir + "/**/*.scss")
.pipe(sass().on('error', sass.logError))
//.pipe(prefix('last 2 version'))
.pipe(gulp.dest(settings.cssDir))
.pipe(browserSync.stream());
});
/**
* Default task, running just `gulp` will compile the sass,
* compile the site, launch BrowserSync then watch
* files for changes
*/
gulp.task('default', ['serve']);