-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathgulpfile.js
executable file
·73 lines (64 loc) · 2.57 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
'use strict';
var gulp = require('gulp');
var HubRegistry = require('gulp-hub');
var dotenv = require('dotenv');
var browserSync = require('browser-sync').create();
/* tell gulp to use the tasks just loaded */
gulp.registry(new HubRegistry(['tasks/*.js']));
// START
const setProduction =(e) => {
global.WebPackMode = global.WebPackMode || "production"
return Promise.resolve('the value is ignored');
}
const setDeveloppement =(e) => {
global.WebPackMode = global.WebPackMode || 'development'
return Promise.resolve('the value is ignored');
}
gulp.task('watcher', () => {
// Graphic tasks
gulp.watch('app/graphics/icons/*.svg', gulp.series(gulp.parallel('iconfont'), gulp.parallel('public-style'), 'autoloader'));
gulp.watch('app/graphics/dashicons/*.svg', gulp.series(gulp.parallel('dashicons'), gulp.parallel('admin-style'), 'autoloader'));
gulp.watch('app/graphics/images/*', gulp.series(gulp.parallel('images'), gulp.parallel('public-style'), 'autoloader'));
// Public Elements
gulp.watch('app/**/*.vue', gulp.series(gulp.parallel('public-script'), 'autoloader'));
gulp.watch('app/**/*.js*', gulp.series(gulp.parallel('public-script'), 'autoloader'));
gulp.watch('app/**/*.*ss', gulp.series(gulp.parallel('admin-style', 'public-style'), 'autoloader')); /** */
// Gutenberg Elements
gulp.watch('components/**/*public.js*', gulp.series(gulp.parallel('public-script'), 'autoloader'));
gulp.watch('components/**/*.js*', gulp.series(gulp.parallel('gutenberg'), 'autoloader'));
gulp.watch('components/**/*.*ss', gulp.series(gulp.parallel('admin-style', 'public-style'), 'autoloader'));
// Autoloader for PHP
gulp.watch(['app/**/*.php'], gulp.parallel('autoloader'));
});
gulp.task('watch', gulp.series(setDeveloppement, 'default', gulp.parallel('browsersync', 'watcher')));
gulp.task('default', gulp.series(
setProduction,
gulp.parallel([
'iconfont',
'dashicons'
]),
gulp.parallel([
'images',
'admin-style',
'public-style',
'public-script'
]),
'autoloader'
));
gulp.task('browsersync', () => {
const env = dotenv.config()
if (!process.env.WP_HOME) {
//require('dotenv').config({ path: __dirname+'/../../../..' })
}
if (process.env.WP_HOME) {
let files = [
'./app/**/*.php',
'./app/*.php',
'./public/**/*.*',
'./*.php'
];
browserSync.init(files, {
proxy: process.env.WP_HOME
});
}
})