forked from JohnProvidence/libcal-for-wordpress
-
Notifications
You must be signed in to change notification settings - Fork 0
/
gulpfile.js
70 lines (62 loc) · 1.6 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
const gulp = require('gulp');
const sass = require('gulp-sass');
const browsersync = require('browser-sync').create();
const cleanCSS = require('gulp-clean-css');
const minify = require('gulp-minify');
function browserSync(done) {
browsersync.init({
proxy: 'http://localhost/ppldev/'
});
done();
}
function browserSyncReload(done) {
browsersync.reload();
done();
}
//Compile SASS files to style.css file.
function css() {
return gulp
.src('sass/**/*.scss')
.pipe(sass())
.pipe(gulp.dest('./'))
.pipe(browsersync.stream());
}
//Minify style.css.
function minifyCSS() {
return gulp
.src('style.css')
.pipe(cleanCSS({debug:true}, function(details) {
console.log(details.name + ': '+details.stats.originalSize);
console.log(details.name + ': '+details.stats.minifiedSize);
}))
.pipe(gulp.dest('./'))
.pipe(browsersync.stream());
}
//Compress javascript files to minified versions in dist folder.
function compressJS(done) {
return gulp
.src(['js/full-calendar.js', 'js/widget.js', 'js/clndr.js', 'js/lcwp-admin.js', 'js/underscore.js', 'js/moment.js', 'js/iScroll.js', 'js/ppl-event-scroll.js'])
.pipe(minify({
ext: {
min: '.min.js'
},
noSource: true
}))
.pipe(gulp.dest('dist'));
done();
}
//Watches folders for changes and invokes the above functions.
function watchFiles() {
gulp.watch('sass/**/*.scss', gulp.series(css, minifyCSS));
gulp.watch('js/*.js', compressJS);
gulp.watch([
'./**/*.php',
'./inc/**/*.php',
'js/**/*.js'
],
gulp.series(browserSyncReload));
}
const watch = gulp.parallel(watchFiles, browserSync);
exports.css = css;
exports.js = compressJS;
exports.watch = watch;