This repository has been archived by the owner on Apr 26, 2022. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 0
/
gulpfile.js
122 lines (111 loc) · 4.34 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
'use strict';
//npm install --save-dev gulp gulp-include gulp-imagemin gulp-minify gulp-wp-pot gulp-sort gulp-zip
//npm install --save-dev gulp
// Dependencies
var gulp = require('gulp');
var minify = require('gulp-minify');
let cleanCss = require('gulp-clean-css');
var rename = require('gulp-rename');
var notify = require('gulp-notify'); // Sends message notification to you
var wpPot = require('gulp-wp-pot'); // For generating the .pot file.
var sort = require('gulp-sort'); // Recommended to prevent unnecessary changes in pot-file.
var zip = require('gulp-zip');
var replace = require('gulp-replace');
// Settings
var wpTheme = "./";
var plugin_name = 'roi-hunter-easy-for-woocommerce';
var zip_files = ['./**/*', '!node_modules/**/*','!.vscode/**/*', '!node_modules', '!gulpfile.js', '!.gitignore', '!package.json', '!package-lock.json', '!*.zip', '!todo.txt', '!*.md'];
// Translation related.
var text_domain = 'roi-hunter-easy'; // Your textdomain here.
var translationFile = 'roi-hunter-easy.pot'; // Name of the transalation file.
var packageName = 'roi-hunter-easy'; // Package name.
var translationDestination = './languages'; // Where to save the translation files.
var bugReport = 'https://kybernaut.cz/kontakt/'; // Where can users report bugs.
var lastTranslator = 'Karolína Vyskočilová <karolina@kybernaut.cz>'; // Last translator Email ID.
var team = 'Kybernaut <karolina@kybernaut.cz>'; // Team's Email ID.
// Watch files paths.
var projectPHPWatchFiles = './**/*.php'; // Path to all PHP files.
/**
* INCLUDE JS SCRIPTS AND MINIFY
* https://www.npmjs.com/package/gulp-include
* https://www.npmjs.com/package/gulp-minify
*/
gulp.task( "js", function(done) {
//console.log( '-- including files to assets/js/admin.js' );
console.log( '-- minifying to assets/js/admin.min.js' );
gulp.src( wpTheme + 'assets/js/admin.js' )
.pipe(minify({
ext:{
//src:'.js',
min:'.min.js'
}
}))
.pipe( gulp.dest( 'assets/js' ) );
//console.log( '-- including files to assets/js/public.js' );
console.log( '-- minifying to assets/js/public.min.js' );
gulp.src( wpTheme + 'assets/js/public.js' )
.pipe(minify({
ext:{
//src:'.js',
min:'.min.js'
}
}))
.pipe( gulp.dest( 'assets/js' ) );
done();
});
gulp.task('css', function(done) {
gulp.src( wpTheme + 'assets/css/admin.css' )
.pipe(cleanCss({
compatibility: 'ie8'
}))
.pipe(rename({
suffix: '.min'
}))
.pipe( gulp.dest( 'assets/css' ) );
done();
});
/**
* WP POT Translation File Generator.
* https://github.com/ahmadawais/WPGulp/blob/master
*
* * This task does the following:
* 1. Gets the source of all the PHP files
* 2. Sort files in stream by path or any custom sort comparator
* 3. Applies wpPot with the variable set at the top of this file
* 4. Generate a .pot file of i18n that can be used for l10n to build .mo file
*/
gulp.task( 'translate', function () {
return gulp.src( projectPHPWatchFiles )
.pipe(sort())
.pipe(wpPot( {
domain : text_domain,
package : packageName,
bugReport : bugReport,
lastTranslator: lastTranslator,
team : team
} ))
.pipe(gulp.dest(translationDestination + '/' + translationFile ))
.pipe( notify( { message: 'TASK: "translate" Completed!', onLast: true } ) )
});
/**
* Generate plugin instalable zip
*/
// activeBeProfile = production
gulp.task('zip', function(done) {
gulp.series('css', 'js', 'translate')(done);
gulp.src( zip_files )
.pipe(zip( plugin_name + '.zip' ))
.pipe(gulp.dest('.'));
}
);
// activeBeProfile = staging
gulp.task('zip-staging', function(done) {
gulp.series('css', 'js', 'translate')(done);
gulp.src( zip_files )
.pipe(replace("'activeBeProfile' => 'production'", "'activeBeProfile' => 'staging'"))
.pipe(replace("https://goostav-fe.roihunter.com/", "https://goostav-fe-staging.roihunter.com/"))
.pipe(replace("https://goostav.roihunter.com/", "https://goostav-staging.roihunter.com/"))
.pipe(zip( plugin_name + '_staging.zip' ))
.pipe(gulp.dest('.'));
}
);