|
1
|
|
|
const gulp = require('gulp'); |
|
2
|
|
|
const rtlcss = require('gulp-rtlcss'); |
|
|
|
|
|
|
3
|
|
|
const sass = require('gulp-sass'); |
|
|
|
|
|
|
4
|
|
|
const sourcemaps = require('gulp-sourcemaps'); |
|
|
|
|
|
|
5
|
|
|
const jshint = require('gulp-jshint'); |
|
6
|
|
|
const concat = require('gulp-concat'); |
|
7
|
|
|
const uglify = require('gulp-uglify'); |
|
8
|
|
|
const sort = require('gulp-sort'); |
|
9
|
|
|
const wppot = require('gulp-wp-pot'); |
|
10
|
|
|
const gettext = require('gulp-gettext'); |
|
11
|
|
|
const plumber = require('gulp-plumber'); |
|
12
|
|
|
const autoprefixer = require('gulp-autoprefixer'); |
|
|
|
|
|
|
13
|
|
|
const gutil = require('gulp-util'); |
|
|
|
|
|
|
14
|
|
|
const rename = require('gulp-rename'); |
|
|
|
|
|
|
15
|
|
|
const minify = require('gulp-minify-css'); |
|
|
|
|
|
|
16
|
|
|
const map = require('map-stream'); |
|
17
|
|
|
const browserlist = ['last 2 version', '> 1%']; |
|
|
|
|
|
|
18
|
|
|
|
|
19
|
|
|
const errorreporter = map(function(file, cb) { |
|
|
|
|
|
|
20
|
|
|
if (file.jshint.success) { |
|
21
|
|
|
return cb(null, file); |
|
22
|
|
|
} |
|
23
|
|
|
|
|
24
|
|
|
console.log('JSHINT fail in', file.path); |
|
|
|
|
|
|
25
|
|
|
|
|
26
|
|
|
file.jshint.results.forEach(function (result) { |
|
27
|
|
|
if (!result.error) { |
|
28
|
|
|
return; |
|
29
|
|
|
} |
|
30
|
|
|
|
|
31
|
|
|
const err = result.error |
|
32
|
|
|
console.log(` line ${err.line}, col ${err.character}, code ${err.code}, ${err.reason}`); |
|
|
|
|
|
|
33
|
|
|
}); |
|
34
|
|
|
|
|
35
|
|
|
cb(null, file); |
|
|
|
|
|
|
36
|
|
|
}); |
|
37
|
|
|
|
|
38
|
|
|
gulp.task('default', function() { |
|
39
|
|
|
console.log('Use the following commands'); |
|
|
|
|
|
|
40
|
|
|
console.log('--------------------------'); |
|
41
|
|
|
console.log('gulp compile-js to compile the js to min.js'); |
|
42
|
|
|
console.log('gulp watch to continue watching the files for changes'); |
|
43
|
|
|
console.log('gulp wordpress-lang to compile the wetu-importer.pot, en_EN.po and en_EN.mo'); |
|
44
|
|
|
}); |
|
45
|
|
|
|
|
46
|
|
|
gulp.task('js', function() { |
|
47
|
|
|
return gulp.src('assets/js/wetu-importer.js') |
|
48
|
|
|
.pipe(plumber({ |
|
49
|
|
|
errorHandler: function(err) { |
|
50
|
|
|
console.log(err); |
|
|
|
|
|
|
51
|
|
|
this.emit('end'); |
|
52
|
|
|
} |
|
53
|
|
|
})) |
|
54
|
|
|
.pipe(jshint()) |
|
55
|
|
|
//.pipe(errorreporter) |
|
56
|
|
|
.pipe(concat('wetu-importer.min.js')) |
|
57
|
|
|
.pipe(uglify()) |
|
58
|
|
|
.pipe(gulp.dest('assets/js')) |
|
59
|
|
|
}); |
|
60
|
|
|
|
|
61
|
|
|
gulp.task('compile-js', ['js']); |
|
62
|
|
|
|
|
63
|
|
|
gulp.task('watch-js', function () { |
|
64
|
|
|
return gulp.watch('assets/js/**/*.js', ['compile-js']); |
|
65
|
|
|
}); |
|
66
|
|
|
|
|
67
|
|
|
gulp.task('watch', ['watch-css', 'watch-js']); |
|
68
|
|
|
|
|
69
|
|
|
gulp.task('wordpress-pot', function() { |
|
70
|
|
|
return gulp.src('**/*.php') |
|
71
|
|
|
.pipe(sort()) |
|
72
|
|
|
.pipe(wppot({ |
|
73
|
|
|
domain: 'wetu-importer', |
|
74
|
|
|
package: 'wetu-importer', |
|
75
|
|
|
team: 'LightSpeed <[email protected]>' |
|
76
|
|
|
})) |
|
77
|
|
|
.pipe(gulp.dest('languages/wetu-importer.pot')) |
|
78
|
|
|
}); |
|
79
|
|
|
|
|
80
|
|
|
gulp.task('wordpress-po', function() { |
|
81
|
|
|
return gulp.src('**/*.php') |
|
82
|
|
|
.pipe(sort()) |
|
83
|
|
|
.pipe(wppot({ |
|
84
|
|
|
domain: 'wetu-importer', |
|
85
|
|
|
package: 'wetu-importer', |
|
86
|
|
|
team: 'LightSpeed <[email protected]>' |
|
87
|
|
|
})) |
|
88
|
|
|
.pipe(gulp.dest('languages/en_EN.po')) |
|
89
|
|
|
}); |
|
90
|
|
|
|
|
91
|
|
|
gulp.task('wordpress-po-mo', ['wordpress-po'], function() { |
|
92
|
|
|
return gulp.src('languages/en_EN.po') |
|
93
|
|
|
.pipe(gettext()) |
|
94
|
|
|
.pipe(gulp.dest('languages')) |
|
95
|
|
|
}); |
|
96
|
|
|
|
|
97
|
|
|
gulp.task('wordpress-lang', (['wordpress-pot', 'wordpress-po-mo'])); |
|
98
|
|
|
|