-
Notifications
You must be signed in to change notification settings - Fork 44
/
gulpfile.js
100 lines (91 loc) · 2.39 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
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
var gulp = require('gulp');
var uglify = require('gulp-uglify-es').default;
var $ = require('gulp-load-plugins')();
var paths = {
src: {
php: './**/*.php',
admin: {
js: './src/js/admin/*.js',
css: './src/css/admin/*.scss'
},
public: {
js: './src/js/public/*.js',
css: './src/css/public/*.scss'
}
},
dest: {
css: './assets/css/',
js: './assets/js/',
pot: './languages/'
}
};
function errorLog(error) {
console.log(error.message);
this.emit('end');
}
gulp.task('pot', function() {
return gulp.src( paths.src.php )
.pipe( $.wpPot( {
domain: 'gdpr'
} ) )
.pipe( gulp.dest( paths.dest.pot + 'gdpr.pot' ) );
});
gulp.task('admin-css', function() {
return gulp.src( paths.src.admin.css )
.pipe( $.sass( {
outputStyle: 'compressed'
} ) )
.on('error', errorLog)
.pipe( $.autoprefixer( 'last 4 versions' ) )
.pipe( $.rename( 'gdpr-admin.css' ) )
.pipe( gulp.dest( paths.dest.css ) )
.pipe( $.livereload() )
.pipe( $.notify( {
message: 'Admin SASS style task complete'
} ) );
});
gulp.task('public-css', function() {
return gulp.src( paths.src.public.css )
.pipe( $.sass( {
outputStyle: 'compressed'
} ) )
.on('error', errorLog)
.pipe( $.autoprefixer( 'last 4 versions' ) )
.pipe( $.rename( 'gdpr-public.css' ) )
.pipe( gulp.dest( paths.dest.css ) )
.pipe( $.livereload() )
.pipe( $.notify( {
message: 'Admin SASS style task complete'
} ) );
});
gulp.task('admin-js', function() {
return gulp.src( paths.src.admin.js )
.pipe( $.concat( 'gdpr-admin.js' ) )
.pipe( uglify() )
.on('error', errorLog)
.pipe( gulp.dest( paths.dest.js ) )
.pipe($.livereload())
.pipe( $.notify( {
message: 'Admin JS script task complete'
} ) );
});
gulp.task('public-js', function() {
return gulp.src( paths.src.public.js )
.pipe( $.concat( 'gdpr-public.js' ) )
.pipe( uglify() )
.on('error', errorLog)
.pipe( gulp.dest( paths.dest.js ) )
.pipe($.livereload())
.pipe( $.notify( {
message: 'Public JS script task complete'
} ) );
});
gulp.task('watch', function(){
$.livereload.listen();
gulp.watch( paths.src.php, $.livereload.reload);
gulp.watch( paths.src.admin.css, ['admin-css']);
gulp.watch( paths.src.public.css, ['public-css']);
gulp.watch( paths.src.admin.js, ['admin-js']);
gulp.watch( paths.src.public.js, ['public-js']);
});
gulp.task('default', ['admin-css', 'public-css', 'admin-js', 'public-js', 'pot', 'watch']);