-
Notifications
You must be signed in to change notification settings - Fork 5
/
gulpfile.js
146 lines (132 loc) · 3.88 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
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
const gulp = require('gulp');
const autoprefixer = require('gulp-autoprefixer');
const gettext = require('gulp-gettext');
const jshint = require('gulp-jshint');
const plumber = require('gulp-plumber');
const rename = require('gulp-rename');
const rtlcss = require('gulp-rtlcss');
const sass = require('gulp-sass');
const sort = require('gulp-sort');
const sourcemaps = require('gulp-sourcemaps');
const uglify = require('gulp-uglify');
const gutil = require('gulp-util');
const wppot = require('gulp-wp-pot');
const browserlist = ['last 2 version', '> 1%'];
gulp.task('default', function() {
console.log('Use the following commands');
console.log('--------------------------');
console.log('gulp compile-css to compile the scss to css');
console.log('gulp compile-js to compile the js to min.js');
console.log('gulp watch to continue watching the files for changes');
console.log('gulp wordpress-lang to compile the lsx-health-plan.pot, lsx-health-plan-en_EN.po and lsx-health-plan-en_EN.mo');
});
gulp.task('styles', function (done) {
return gulp.src('assets/css/scss/*.scss')
.pipe(plumber({
errorHandler: function(err) {
console.log(err);
this.emit('end');
}
}))
.pipe(sourcemaps.init())
.pipe(sass({
outputStyle: 'compact',
includePaths: ['assets/css/scss']
}).on('error', gutil.log))
.pipe(autoprefixer({
browsers: browserlist,
casacade: true
}))
.pipe(sourcemaps.write('maps'))
.pipe(gulp.dest('assets/css')),
done();
});
gulp.task('styles-rtl', function (done) {
return gulp.src('assets/css/scss/*.scss')
.pipe(plumber({
errorHandler: function(err) {
console.log(err);
this.emit('end');
}
}))
.pipe(sass({
outputStyle: 'compact',
includePaths: ['assets/css/scss']
}).on('error', gutil.log))
.pipe(autoprefixer({
browsers: browserlist,
casacade: true
}))
.pipe(rtlcss())
.pipe(rename({
suffix: '-rtl'
}))
.pipe(gulp.dest('assets/css')),
done();
});
gulp.task('compile-css', gulp.series( ['styles', 'styles-rtl'] , function(done) {
done();
}));
gulp.task('js', function(done) {
return gulp.src('assets/js/src/**/*.js')
.pipe(plumber({
errorHandler: function(err) {
console.log(err);
this.emit('end');
}
}))
.pipe(jshint())
.pipe(uglify())
.pipe(rename({
suffix: '.min'
}))
.pipe(gulp.dest('assets/js')),
done();
});
gulp.task('compile-js', gulp.series( ['js'] , function(done) {
done();
}));
gulp.task('watch-css', function (done) {
done();
return gulp.watch('assets/css/**/*.scss', gulp.series('compile-css'));
});
gulp.task('watch-js', function (done) {
done();
return gulp.watch('assets/js/src/**/*.js', gulp.series('compile-js'));
});
gulp.task('watch', gulp.series( ['watch-css', 'watch-js'] , function(done) {
done();
}));
gulp.task('wordpress-pot', function(done) {
return gulp.src('**/*.php')
.pipe(sort())
.pipe(wppot({
domain: 'lsx-health-plan',
package: 'lsx-health-plan',
bugReport: 'https://github.com/lightspeeddevelopment/lsx-health-plan/issues',
team: 'LightSpeed <webmaster@lsdev.biz>'
}))
.pipe(gulp.dest('languages/lsx-health-plan.pot')),
done();
});
gulp.task('wordpress-po', function(done) {
return gulp.src('**/*.php')
.pipe(sort())
.pipe(wppot({
domain: 'lsx-health-plan',
package: 'lsx-health-plan',
bugReport: 'https://github.com/lightspeeddevelopment/lsx-health-plan/issues',
team: 'LightSpeed <webmaster@lsdev.biz>'
}))
.pipe(gulp.dest('languages/lsx-health-plan-en_EN.po')),
done();
});
gulp.task('wordpress-po-mo', gulp.series( ['wordpress-po'], function(done) {
return gulp.src('languages/lsx-health-plan-en_EN.po')
.pipe(gettext())
.pipe(gulp.dest('languages')),
done();
}));
gulp.task('wordpress-lang', gulp.series( ['wordpress-pot', 'wordpress-po-mo'] , function(done) {
done();
}));