-
Notifications
You must be signed in to change notification settings - Fork 1
/
gulpfile.js
74 lines (64 loc) · 2.06 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
const gulp = require('gulp');
const gettext = require('gulp-gettext');
const jshint = require('gulp-jshint');
const plumber = require('gulp-plumber');
const rename = require('gulp-rename');
const sort = require('gulp-sort');
const uglify = require('gulp-uglify');
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-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 to-maps.pot, to-maps-en_EN.po and to-maps-en_EN.mo');
});
gulp.task('js', function() {
return gulp.src('assets/js/to-maps.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'))
});
gulp.task('compile-js', (['js']));
gulp.task('watch-js', function () {
return gulp.watch('assets/js/src/**/*.js', ['compile-js']);
});
gulp.task('watch', ['watch-js']);
gulp.task('wordpress-pot', function() {
return gulp.src('**/*.php')
.pipe(sort())
.pipe(wppot({
domain: 'to-maps',
package: 'to-maps',
bugReport: 'https://github.com/lightspeeddevelopment/to-maps/issues',
team: 'LightSpeed <[email protected]>'
}))
.pipe(gulp.dest('languages/to-maps.pot'))
});
gulp.task('wordpress-po', function() {
return gulp.src('**/*.php')
.pipe(sort())
.pipe(wppot({
domain: 'to-maps',
package: 'to-maps',
bugReport: 'https://www.lsdev.biz/product/to-maps-maps/issues',
team: 'LightSpeed <[email protected]>'
}))
.pipe(gulp.dest('languages/to-maps-en_EN.po'))
});
gulp.task('wordpress-po-mo', ['wordpress-po'], function() {
return gulp.src('languages/to-maps-en_EN.po')
.pipe(gettext())
.pipe(gulp.dest('languages'))
});
gulp.task('wordpress-lang', (['wordpress-pot', 'wordpress-po-mo']));