forked from woocommerce/sensei-course-participants
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathgulpfile.js
104 lines (91 loc) · 2.13 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
const { dest, parallel, series, src } = require( 'gulp' );
const del = require( 'del' );
const minify = require('gulp-minify');
const sass = require( 'gulp-sass' );
const wpPot = require( 'gulp-wp-pot' );
const zip = require( 'gulp-zip' );
const buildDir = 'build/sensei-course-participants';
function clean() {
return del( [ 'build' ] );
}
function css() {
return src( 'assets/css/*.scss')
.pipe( sass( { outputStyle: 'expanded' } ) )
.pipe( dest( 'assets/css' ) )
.pipe( dest( buildDir + '/assets/css' ) )
}
function cssMinify() {
return src( 'assets/css/*.scss')
.pipe( sass( { outputStyle: 'compressed' } ) )
.pipe( dest( buildDir + '/assets/css' ) )
}
function docs() {
return src( [ 'changelog.txt', 'README.md' ] )
.pipe( dest( buildDir ) )
}
function js() {
return src( 'assets/js/*.js')
.pipe( dest( buildDir + '/assets/js' ) )
}
function jsMinify() {
return src( 'assets/js/*.js')
.pipe( minify( {
ext:{ min:'.js' },
noSource: true
} ) )
.pipe( dest( buildDir + '/assets/js' ) )
}
function languages() {
return src( 'languages/*.*', { base: '.' } )
.pipe( dest( buildDir ) );
}
function php() {
return src( [ 'sensei-course-participants.php', 'includes/**/*.php' ], { base: '.' } )
.pipe( dest( buildDir ) )
}
function pot() {
return src( [ 'sensei-course-participants.php', 'includes/**/*.php' ] )
.pipe( wpPot( {
domain: 'sensei-course-participants',
package: 'Sensei Course Participants',
} ) )
.pipe( dest( 'languages/sensei-course-participants.pot' ) );
}
function zipFiles() {
return src( buildDir + '/**/*', { base: buildDir + '/..' } )
.pipe( zip( buildDir + '.zip' ) )
.pipe( dest( '.' ) );
}
exports.clean = clean;
exports.css = css;
exports.docs = docs;
exports.js = js;
exports.languages = languages;
exports.php = php;
exports.pot = pot;
exports.zipFiles = zipFiles;
if ( process.env.NODE_ENV === 'dev' ) {
exports.package = series(
clean,
parallel(
css,
docs,
js,
series( pot, languages ),
php,
),
zipFiles,
);
} else {
exports.package = series(
clean,
parallel(
cssMinify,
docs,
jsMinify,
series( pot, languages ),
php,
),
zipFiles,
);
}