-
Notifications
You must be signed in to change notification settings - Fork 0
/
gulpfile.js
74 lines (67 loc) · 1.93 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 plumber = require( 'gulp-plumber' )
const sass = require( 'gulp-sass' )(require('sass'))
const prefix = require( 'gulp-autoprefixer' )
const wpPot = require( 'gulp-wp-pot' )
const sort = require( 'gulp-sort' )
const zip = require( 'gulp-zip' )
const rtlcss = require( 'gulp-rtlcss' )
const rename = require( 'gulp-rename' )
const pkg = require('./package.json')
// CSS
function css() {
return gulp.src('./scss/*.scss')
.pipe(plumber())
.pipe(sass({ outputStyle: 'expanded', includePaths: ['scss'] }).on('error', sass.logError))
.pipe(prefix(['last 30 versions', '> 1%', 'ie 8', 'ie 7'], { cascade: true }))
.pipe(gulp.dest('./'))
}
// RTL CSS
function rtl() {
return gulp.src('./style.css')
.pipe(rtlcss())
.pipe(rename({ suffix: '-rtl' }))
.pipe(gulp.dest('./'))
}
// Pot
function pot() {
return gulp.src('./**/*.php')
.pipe(plumber())
.pipe(sort())
.pipe(wpPot({
domain: pkg.name,
package: pkg.name,
bugReport: pkg.bugs.url,
lastTranslator: `${pkg.author.name} <${pkg.author.email}>`,
team: `${pkg.author.name} <${pkg.author.email}>`
}))
.pipe(gulp.dest(`./languages/${pkg.name}.pot`))
}
// Package
function package() {
return gulp.src( [
'./*.php',
'./inc/**/*',
'./template-parts/**/*',
'./*.css',
'./assets/**/*',
'./languages/**/*',
'LICENSE',
'readme.txt',
'screenshot.png',
], {
base: '.'
})
.pipe(zip(`${pkg.name}_${pkg.version}.zip`))
.pipe(gulp.dest('./releases'))
}
// Watch
function watch() {
gulp.watch('scss/**/*.scss', {cwd: './', usePolling: true}, gulp.series( css, rtl ) )
gulp.watch('**/*.php', {cwd: './', usePolling: true}, pot)
}
module.exports.css = css
module.exports.rtl = rtl
module.exports.pot = pot
module.exports.dev = gulp.series(css, rtl, pot, watch)
module.exports.build = gulp.series(css, rtl, pot, package)