-
Notifications
You must be signed in to change notification settings - Fork 0
/
gulpfile.js
117 lines (104 loc) · 4 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
/**
* Gulpfile.
*
* Gulp with WordPress.
*
* Implements:
* 1. Live reloads browser with BrowserSync.
* 2. CSS: Sass to CSS conversion, error catching, Autoprefixing, Sourcemaps,
* CSS minification, and Merge Media Queries.
* 3. JS: Concatenates & uglifies Vendor and Custom JS files.
* 4. Images: Minifies PNG, JPEG, GIF and SVG images.
* 5. Watches files for changes in CSS or JS.
* 6. Watches files for changes in PHP.
* 7. Corrects the line endings.
* 8. InjectCSS instead of browser page reload.
* 9. Generates .pot file for i18n and l10n.
*
* @author Ahmad Awais (@ahmadawais)
* @version 1.0.3
*/
/**
* Configuration.
*
* Project Configuration for gulp tasks.
*
* In paths you can add <<glob or array of globs>>. Edit the variables as per your project requirements.
*/
// START Editing Project Variables.
// Project related.
var project = 'woocommerce-product-image-gallery-options'; // Project Name.
// Translation related.
var text_domain = 'woocommerce-product-image-gallery-options'; // Your textdomain here.
var destFile = 'woocommerce-product-image-gallery-options.pot'; // Name of the transalation file.
var packageName = 'woocommerce-product-image-gallery-options'; // Package name.
var bugReport = 'https://createandcode.com/support'; // Where can users report bugs.
var lastTranslator = 'Colm Troy <[email protected]>'; // Last translator Email ID.
var team = 'Create and Code <[email protected]>'; // Team's Email ID.
var translatePath = './languages' // Where to save the translation files.
// Browsers you care about for autoprefixing.
// Browserlist https ://github.com/ai/browserslist
const AUTOPREFIXER_BROWSERS = [
'last 2 version',
'> 1%',
'ie >= 9',
'ie_mob >= 10',
'ff >= 30',
'chrome >= 34',
'safari >= 7',
'opera >= 23',
'ios >= 7',
'android >= 4',
'bb >= 10'
];
// STOP Editing Project Variables.
/**
* Load Plugins.
*
* Load gulp plugins and assing them semantic names.
*/
var gulp = require('gulp'); // Gulp of-course
// Utility related plugins.
var lineec = require('gulp-line-ending-corrector'); // Consistent Line Endings for non UNIX systems. Gulp Plugin for Line Ending Corrector (A utility that makes sure your files have consistent line endings)
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.
// Watch files paths.
var projectPHPWatchFiles = './**/*.php'; // Path to all PHP files.
/**
* Load Plugins.
*
* Load gulp plugins and assing them semantic names.
*/
var gulp = require('gulp'); // Gulp of-course
/**
* WP POT Translation File Generator.
*
* * 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,
destFile : destFile,
package : packageName,
bugReport : bugReport,
lastTranslator: lastTranslator,
team : team
} ))
.pipe(gulp.dest(translatePath))
.pipe( notify( { message: 'TASK: "translate" Completed! 💯', onLast: true } ) )
});
/**
* Watch Tasks.
*
* Watches for file changes and runs specific tasks.
*/
gulp.task( 'default', ['styles', 'vendorsJs', 'customJS', 'images', 'browser-sync'], function () {
gulp.watch( projectPHPWatchFiles, reload ); // Reload on PHP file changes.
});