forked from Seravo/wordpress
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathgulpfile.js
64 lines (59 loc) · 1.9 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
/*
* This is default barebone for gulp, add your own modifications here
* It also serves as an example of how to use browser-sync in this environment
*/
const gulp = require('gulp');
const browserSync = require('browser-sync');
const sass = require('gulp-sass')(require('sass'));
const reload = browserSync.reload;
/*
* src array contains the files which the gulp will be watching
* Choose your theme over here
*/
var src = {
scss: 'htdocs/wp-content/themes/yourtheme/scss/*.scss',
css: 'htdocs/wp-content/themes/yourtheme/css',
php: [
'htdocs/wp-content/themes/*/*.php',
'htdocs/wp-content/plugins/*/*.php',
'htdocs/wp-content/mu-plugins/*/*.php',
],
};
// Compile sass into CSS
gulp.task('sass', () => {
return gulp
.src(src.scss)
.pipe(sass())
.pipe(gulp.dest(src.css))
.pipe(reload({ stream: true }));
});
// Serve all files through browser-sync
gulp.task(
'serve',
gulp.series('sass', () => {
// Initialize browsersync
// Nginx is configured to use any service in port 1337
// as middleware to WordPress in vagrant environment
browserSync.init({
// browsersync with a php server
proxy: `https://${process.env.DEFAULT_DOMAIN}`,
open: false,
port: 1337,
ui: {
port: 1338,
},
notify: true,
});
// Watch sass files and compile them. Use polling because the Virtualbox
// shared folders implementation does not emit file system events from the
// host to the VM: https://github.com/floatdrop/gulp-watch/issues/213.
gulp.watch(src.scss, { usePolling: true }, gulp.series('sass'));
// Update the page automatically if php files change
gulp.watch(src.php, { usePolling: true }).on('change', reload);
})
);
// Give another name for serve
gulp.task('watch', gulp.series('serve'));
// Default task just compiles everything
// This is run when site is deployed!
gulp.task('default', gulp.series('sass'));