-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathgulpfile.js
executable file
·67 lines (54 loc) · 1.69 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
58
59
60
61
62
63
64
65
66
67
var gulp = require('gulp');
var browserSync = require('browser-sync').create();
var $ = require('gulp-load-plugins')();
var path = {
source : {
scss : "./assets/src/scss/**/*.scss",
php : "./**/*.php"
},
dist : {
scss : "./assets/dist/css",
}
}
gulp.task('sass-dev', function () {
return gulp
.src( path.source.scss )
.pipe($.size({ showFiles: true }))
.pipe($.plumber({ errorHandler: $.notify.onError("Error: <%= error.message %>") }))
.pipe($.sourcemaps.init())
.pipe($.sassLint())
.pipe($.sassLint.format())
.pipe($.sassLint.failOnError())
.pipe($.sass())
.pipe($.autoprefixer({ browsers: ['last 2 versions'], cascade: false }))
.pipe($.size({ showFiles: true }))
.pipe($.sourcemaps.write('css'))
.pipe(gulp.dest( path.dist.scss ))
.pipe(browserSync.stream({ match: '**/*.css' }))
;
});
gulp.task('sass-build', function () {
return gulp
.src( path.source.scss )
.pipe($.size({ showFiles: true }))
.pipe($.plumber({ errorHandler: $.notify.onError("Error: <%= error.message %>") }))
.pipe($.sass({ outputStyle: 'compressed' }))
.pipe($.size({ showFiles: true }))
.pipe($.autoprefixer({ browsers: ['last 2 versions'], cascade: false }))
.pipe($.size({ showFiles: true }))
.pipe($.cssnano())
.pipe($.size({ showFiles: true }))
.pipe(gulp.dest( path.dist.scss ))
.pipe(browserSync.stream({ match: '**/*.css' }))
;
});
// Static Server + watching scss/html files
gulp.task('serve', function() {
browserSync.init({
proxy: "http://faster.wp"
});
gulp.watch( path.source.scss, gulp.series("sass-dev"));
gulp.watch( path.source.php ).on('change', browserSync.reload);
});
// Creating a default task
gulp.task("default", gulp.series("sass-dev", "serve"));