-
Notifications
You must be signed in to change notification settings - Fork 0
/
gulpfile.js
73 lines (63 loc) · 1.92 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
68
69
70
71
72
73
const gulp = require('gulp');
const gutil = require('gulp-util');
const concat = require('gulp-concat');
const uglify = require('gulp-uglify');
const sass = require('gulp-sass');
const imageMin = require('gulp-imagemin');
const browserSync = require('browser-sync');
const plumber = require('gulp-plumber');
const cleanCSS = require('gulp-clean-css');
const remove = require('gulp-rm');
const fileExists = require('file-exists');
const config = require('./config.json');
gulp.task('browserSync', function () {
browserSync({
proxy: config.devUrl,
options: {
reloadDelay: 250
},
notify: true
});
});
gulp.task('css', function () {
return gulp.src(config.cssFiles)
.pipe(plumber())
.pipe(concat('build.css'))
.pipe(gulp.dest('build/css'))
.pipe(browserSync.reload({stream: true}));
});
gulp.task('scripts', function () {
return gulp.src(config.jsFiles)
.pipe(plumber())
.pipe(concat('build.js'))
.on('error', gutil.log)
.pipe(gulp.dest('build/js'))
.pipe(browserSync.reload({stream: true}));
});
gulp.task('sass', function () {
return gulp.src(['src/sass/style.scss'])
.pipe(plumber({
errorHandler: function (err) {
console.log(err);
this.emit('end');
}
}))
.pipe(sass({
errLogToConsole: true,
includePaths: [
'src/sass'
]
}))
.on('error', gutil.log)
.pipe(gulp.dest('src/css'))
.pipe(browserSync.reload({stream: true}));
});
gulp.task('watch', function () {
gulp.watch("*.php").on('change', function(){
browserSync.reload({stream: true});
});
gulp.watch('src/sass/**', ['sass']);
gulp.watch('src/js/**', ['scripts']);
gulp.watch('src/css/**', ['css']);
});
gulp.task('default', ['scripts', 'sass', 'css', 'browserSync', 'watch']);