-
Notifications
You must be signed in to change notification settings - Fork 1
/
gulpfile.babel.js
871 lines (834 loc) · 25.7 KB
/
gulpfile.babel.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
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
/**
* 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.
*
* @basedon https://github.com/ahmadawais/WPGulp
* @author Nico Andrade <https://twitter.com/NicoAndrade/>
*/
/**
* Load WPGulp Configuration.
*
* TODO: Customize your project in the wpgulp.js file.
*/
const config = require("./wpgulp.config.js");
/**
* Load Plugins.
*
* Load gulp plugins and passing them semantic names.
*/
const gulp = require("gulp"); // Gulp of-course.
// CSS related plugins.
const sass = require("gulp-sass"); // Gulp plugin for Sass compilation.
const minifycss = require("gulp-uglifycss"); // Minifies CSS files.
const autoprefixer = require("gulp-autoprefixer"); // Autoprefixing magic.
const rtlcss = require("gulp-rtlcss"); // Generates RTL stylesheet.
// JS related plugins.
const concat = require("gulp-concat"); // Concatenates JS files.
const uglify = require("gulp-uglify"); // Minifies JS files.
const babel = require("gulp-babel"); // Compiles ESNext to browser compatible JS.
// Image related plugins.
const imagemin = require("gulp-imagemin"); // Minify PNG, JPEG, GIF and SVG images with imagemin.
// Utility related plugins.
const rename = require("gulp-rename"); // Renames files E.g. style.css -> style.min.css.
const 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).
const filter = require("gulp-filter"); // Enables you to work on a subset of the original files by filtering them using a glob.
const sourcemaps = require("gulp-sourcemaps"); // Maps code in a compressed file (E.g. style.css) back to it’s original position in a source file (E.g. structure.scss, which was later combined with other css files to generate style.css).
const notify = require("gulp-notify"); // Sends message notification to you.
const browserSync = require("browser-sync").create(); // Reloads browser and injects CSS. Time-saving synchronized browser testing.
const wpPot = require("gulp-wp-pot"); // For generating the .pot file.
const sort = require("gulp-sort"); // Recommended to prevent unnecessary changes in pot-file.
const cache = require("gulp-cache"); // Cache files in stream for later use.
const remember = require("gulp-remember"); // Adds all the files it has ever seen back into the stream.
const plumber = require("gulp-plumber"); // Prevent pipe breaking caused by errors from gulp plugins.
const beep = require("beepbeep");
// Custom Gulp
const zip = require("gulp-zip");
const merge = require("merge-stream");
const replace = require("gulp-replace");
const params = require("yargs").argv;
const changeCase = require("change-case");
const del = require("del");
/**
* Function: `compileCSS`.
*
* Compiles Sass, Autoprefixes it and Minifies CSS in a function to reuse it
*
*/
function compileCSS(fileSource, folderDestination, consoleMessage) {
return gulp
.src(fileSource, {
allowEmpty: true
})
.pipe(plumber(errorHandler))
.pipe(
sourcemaps.init({
largeFile: true
})
)
.pipe(
sass({
errLogToConsole: config.errLogToConsole,
outputStyle: config.outputStyle,
precision: config.precision
})
)
.on("error", sass.logError)
.pipe(autoprefixer(config.BROWSERS_LIST))
.pipe(lineec()) // Consistent Line Endings for non UNIX systems.
.pipe(gulp.dest(folderDestination))
.pipe(filter("**/*.css")) // Filtering stream to only css files.
.pipe(lineec()) // Consistent Line Endings for non UNIX systems.
.pipe(gulp.dest(folderDestination))
.pipe(filter("**/*.css")) // Filtering stream to only css files.
.pipe(browserSync.stream()) // Reloads style.min.css if that is enqueued.
.pipe(
notify({
message: "\n\n✅ ===> " + consoleMessage + " — completed!\n",
onLast: true
})
);
}
/**
* Custom Error Handler.
*
* @param Mixed err
*/
const errorHandler = r => {
notify.onError("\n\n❌ ===> ERROR: <%= error.message %>\n")(r);
beep();
// this.emit('end');
};
/**
* Task: `browser-sync`.
*
* Live Reloads, CSS injections, Localhost tunneling.
* @link http://www.browsersync.io/docs/options/
*
* @param {Mixed} done Done.
*/
const browsersync = done => {
browserSync.init({
proxy: config.projectURL,
open: config.browserAutoOpen,
injectChanges: config.injectChanges,
watchEvents: ["change", "add", "unlink", "addDir", "unlinkDir"]
});
done();
};
// Helper function to allow browser reload with Gulp 4.
const reload = done => {
browserSync.reload();
done();
};
/**
* Task: `styles`.
*
* Compiles Sass, Autoprefixes it and Minifies CSS.
*
* This task does the following:
* 1. Gets the source scss file
* 2. Compiles Sass to CSS
* 3. Writes Sourcemaps for it
* 4. Autoprefixes it and generates style.css
* 5. Renames the CSS file with suffix .min.css
* 6. Minifies the CSS file and generates style.min.css
* 7. Injects CSS or reloads the browser via browserSync
*/
gulp.task("styles", () => {
return gulp
.src(config.styleSRC, {
allowEmpty: true
})
.pipe(plumber(errorHandler))
.pipe(
sourcemaps.init({
largeFile: true
})
)
.pipe(
sass({
errLogToConsole: config.errLogToConsole,
outputStyle: config.outputStyle,
precision: config.precision
})
)
.on("error", sass.logError)
.pipe(
sourcemaps.write({
includeContent: false
})
)
.pipe(
sourcemaps.init({
loadMaps: true
})
)
.pipe(autoprefixer(config.BROWSERS_LIST))
.pipe(sourcemaps.write("./"))
.pipe(lineec()) // Consistent Line Endings for non UNIX systems.
.pipe(gulp.dest(config.styleDestination))
.pipe(filter("**/*.css")) // Filtering stream to only css files.
.pipe(browserSync.stream()) // Reloads style.min.css if that is enqueued.
.pipe(
notify({
message: "\n\n✅ ===> STYLES — completed!\n",
onLast: true
})
);
});
/**
* Task: `adminStyles`.
*
* Compiles Sass, Autoprefixes it and Minifies CSS.
*
*/
gulp.task("adminStyles", () => {
return compileCSS(
config.adminStyleSRC,
config.adminStyleDestination,
"ADMIN STYLES"
);
});
/**
* Task: `editorStyles`.
*
* Compiles Sass, Autoprefixes it and Minifies CSS.
*
*/
gulp.task("editorStyles", () => {
return compileCSS(
config.editorStylesSRC,
config.editorStylesDestination,
"EDITOR STYLES"
);
});
/**
* Task: `stylesBuild`.
*
* Does everything the same as 'styles' but minifys the style.css for production
*
*/
gulp.task("stylesBuild", () => {
return compileCSS(config.styleSRC, config.styleDestination, "STYLES BUILD");
});
/**
* Task: `stylesRTL`.
*
* Compiles Sass, Autoprefixes it, Generates RTL stylesheet, and Minifies CSS.
*
* This task does the following:
* 1. Gets the source scss file
* 2. Compiles Sass to CSS
* 4. Autoprefixes it and generates style.css
* 5. Renames the CSS file with suffix -rtl and generates style-rtl.css
* 6. Writes Sourcemaps for style-rtl.css
* 7. Renames the CSS files with suffix .min.css
* 8. Minifies the CSS file and generates style-rtl.min.css
* 9. Injects CSS or reloads the browser via browserSync
*/
gulp.task("stylesRTL", () => {
return gulp
.src(config.styleSRC, {
allowEmpty: true
})
.pipe(plumber(errorHandler))
.pipe(sourcemaps.init())
.pipe(
sass({
errLogToConsole: config.errLogToConsole,
outputStyle: config.outputStyle,
precision: config.precision
})
)
.on("error", sass.logError)
.pipe(
sourcemaps.write({
includeContent: false
})
)
.pipe(
sourcemaps.init({
loadMaps: true
})
)
.pipe(autoprefixer(config.BROWSERS_LIST))
.pipe(lineec()) // Consistent Line Endings for non UNIX systems.
.pipe(
rename({
suffix: "-rtl"
})
) // Append "-rtl" to the filename.
.pipe(rtlcss()) // Convert to RTL.
.pipe(sourcemaps.write("./")) // Output sourcemap for style-rtl.css.
.pipe(gulp.dest(config.styleDestination))
.pipe(filter("**/*.css")) // Filtering stream to only css files.
.pipe(browserSync.stream()) // Reloads style.css or style-rtl.css, if that is enqueued.
.pipe(
rename({
suffix: ".min"
})
)
.pipe(
minifycss({
maxLineLen: 10
})
)
.pipe(lineec()) // Consistent Line Endings for non UNIX systems.
.pipe(gulp.dest(config.styleDestination))
.pipe(filter("**/*.css")) // Filtering stream to only css files.
.pipe(browserSync.stream()) // Reloads style.css or style-rtl.css, if that is enqueued.
.pipe(
notify({
message: "\n\n✅ ===> STYLES RTL — completed!\n",
onLast: true
})
);
});
/**
* Task: `vendorsJS`.
*
* Concatenate and uglify vendor JS scripts.
*
* This task does the following:
* 1. Gets the source folder for JS vendor files
* 2. Concatenates all the files and generates vendors.js
* 3. Renames the JS file with suffix .min.js
* 4. Uglifes/Minifies the JS file and generates vendors.min.js
*/
gulp.task("vendorsJS", () => {
return gulp
.src(config.jsVendorSRC, {
since: gulp.lastRun("vendorsJS")
}) // Only run on changed files.
.pipe(plumber(errorHandler))
.pipe(remember(config.jsVendorSRC)) // Bring all files back to stream.
.pipe(concat(config.jsVendorFile + ".js"))
.pipe(lineec()) // Consistent Line Endings for non UNIX systems.
.pipe(gulp.dest(config.jsVendorDestination))
.pipe(
rename({
basename: config.jsVendorFile,
suffix: ".min"
})
)
.pipe(uglify())
.pipe(lineec()) // Consistent Line Endings for non UNIX systems.
.pipe(gulp.dest(config.jsVendorDestination))
.pipe(
notify({
message: "\n\n✅ ===> VENDOR JS — completed!\n",
onLast: true
})
);
});
/**
* Task: `customJS`.
*
* Concatenate and uglify custom JS scripts.
*
* This task does the following:
* 1. Gets the source folder for JS custom files
* 2. Concatenates all the files and generates custom.js
* 3. Renames the JS file with suffix .min.js
* 4. Uglifes/Minifies the JS file and generates custom.min.js
*/
gulp.task("customJS", () => {
return gulp
.src(config.jsCustomSRC, {
since: gulp.lastRun("customJS")
}) // Only run on changed files.
.pipe(plumber(errorHandler))
.pipe(
babel({
presets: [
[
"@babel/preset-env", // Preset to compile your modern JS to ES5.
{
targets: {
browsers: config.BROWSERS_LIST
} // Target browser list to support.
}
]
]
})
)
.pipe(remember(config.jsCustomSRC)) // Bring all files back to stream.
.pipe(concat(config.jsCustomFile + ".js"))
.pipe(lineec()) // Consistent Line Endings for non UNIX systems.
.pipe(gulp.dest(config.jsCustomDestination))
.pipe(
rename({
basename: config.jsCustomFile,
suffix: ".min"
})
)
.pipe(uglify())
.pipe(lineec()) // Consistent Line Endings for non UNIX systems.
.pipe(gulp.dest(config.jsCustomDestination))
.pipe(
notify({
message: "\n\n✅ ===> CUSTOM JS — completed!\n",
onLast: true
})
);
});
/**
* Task: `images`.
*
* Minifies PNG, JPEG, GIF and SVG images.
*
* This task does the following:
* 1. Gets the source of images raw folder
* 2. Minifies PNG, JPEG, GIF and SVG images
* 3. Generates and saves the optimized images
*
* This task will run only once, if you want to run it
* again, do it with the command `gulp images`.
*
* Read the following to change these options.
* @link https://github.com/sindresorhus/gulp-imagemin
*/
gulp.task("images", () => {
return gulp
.src(config.imgSRC)
.pipe(
cache(
imagemin([
imagemin.gifsicle({
interlaced: true
}),
imagemin.jpegtran({
progressive: true
}),
imagemin.optipng({
optimizationLevel: 3
}), // 0-7 low-high.
imagemin.svgo({
plugins: [
{
removeViewBox: true
},
{
cleanupIDs: false
}
]
})
])
)
)
.pipe(gulp.dest(config.imgDST))
.pipe(
notify({
message: "\n\n✅ ===> IMAGES — completed!\n",
onLast: true
})
);
});
/**
* Task: `clear-images-cache`.
*
* Deletes the images cache. By running the next "images" task,
* each image will be regenerated.
*/
gulp.task("clearCache", function(done) {
return cache.clearAll(done);
});
/**
* 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", () => {
return gulp
.src(config.watchPhp)
.pipe(sort())
.pipe(
wpPot({
domain: config.textDomain,
package: config.packageName,
bugReport: config.bugReport,
lastTranslator: config.lastTranslator,
team: config.team
})
)
.pipe(
gulp.dest(
config.translationDestination + "/" + config.translationFile
)
)
.pipe(
notify({
message: "\n\n✅ ===> TRANSLATE — completed!\n",
onLast: true
})
);
});
/**
* Task: `readmeMarkdown`.
*
* Creates a readme.md from the original readme.txt
*
*/
gulp.task("readmeMarkdown", () => {
return gulp
.src(["./readme.txt"])
.pipe(replace(/===(.*)===/g, "#$1")) // Replace titles with MD #
.pipe(replace(/==(.*)==/g, "##$1"))
.pipe(replace(/=(.*)=/g, "####$1"))
.pipe(replace("Contributors:", "**Contributors:**"))
.pipe(replace("Author:", "**Author:**"))
.pipe(replace("Requires at least:", "**Requires at least:**"))
.pipe(replace("Tested up to:", "**Tested up to:**"))
.pipe(replace("Stable tag:", "**Stable tag:**"))
.pipe(replace("License:", "**License:**"))
.pipe(replace("License URI:", "**License URI:**"))
.pipe(replace("Source:", "**Source:**"))
.pipe(replace("Tags:", "**Tags:**"))
.pipe(
rename({
extname: ".md"
})
)
.pipe(gulp.dest("./"))
.pipe(
notify({
message: "\n\n✅ ===> README MARKDOWN — completed!\n",
onLast: true
})
);
});
/**
* Watch Tasks.
*
* Watches for file changes and runs specific tasks.
*/
gulp.task(
"default",
gulp.parallel(
"styles",
"adminStyles",
"editorStyles",
"vendorsJS",
"customJS",
"images",
"readmeMarkdown",
browsersync,
() => {
gulp.watch(config.watchPhp, reload); // Reload on PHP file changes.
gulp.watch(
config.watchStyles,
gulp.parallel("styles", "adminStyles", "editorStyles")
); // Reload on SCSS file changes.
gulp.watch(config.watchJsVendor, gulp.series("vendorsJS", reload)); // Reload on vendorsJS file changes.
gulp.watch(config.watchJsCustom, gulp.series("customJS", reload)); // Reload on customJS file changes.
gulp.watch(config.imgSRC, gulp.series("images", reload)); // Reload on customJS file changes.
gulp.watch("./readme.txt", gulp.series("readmeMarkdown")); // Creates Markdown file from readme.txt
}
)
);
/**
* Task: `moveFiles`.
*
* Creates a ZIP file with only the necessary files.
*
* This task will run only once, if you want to run it
* again, do it with the command `gulp moveFiles`.
*
*/
gulp.task("moveFiles", () => {
return gulp
.src([
"./**/*",
"!./{images/raw,images/raw/**/*}",
"!./{node_modules,node_modules/**/*}",
"!./assets/{sass,sass/*}",
"!./assets/css/vendor/{bootstrap,bootstrap/**/*}",
"!./assets/css/vendor/fontawesome-free/{scss,scss/**/*}",
"!./assets/css/vendor/quemalabs-font/style.scss",
"!./assets/css/vendor/quemalabs-font/style.css",
"!./gulpfile.js",
"!./package.json",
"!./package-lock.json",
"!**.DS_Store*",
"!Thumbs.db",
"!./gulpfile.babel.js",
"!./wpgulp.config.js",
"!./*.codekit3",
"!./.gitignore",
"!./style.scss",
"!./style.less",
"!./dist/"
])
.pipe(gulp.dest("./dist/" + config.textDomain + "/"))
.pipe(
notify({
message: "\n\n✅ ===> FILES MOVED — completed!\n",
onLast: true
})
);
});
/**
* Task: `zip`.
*
* Creates a ZIP file with only the necessary files.
*
* This task will run only once, if you want to run it
* again, do it with the command `gulp zip`.
*
*/
gulp.task("zip", () => {
return gulp
.src([
"./dist/**/*",
"!./{images/raw,images/raw/**/*}",
"!./{node_modules,node_modules/**/*}",
"!./assets/{sass,sass/*}",
"!./assets/css/vendor/{bootstrap,bootstrap/**/*}",
"!./assets/css/vendor/fontawesome-free/{scss,scss/**/*}",
"!./assets/css/vendor/quemalabs-font/style.scss",
"!./assets/css/vendor/quemalabs-font/style.css",
"!./gulpfile.js",
"!./package.json",
"!./package-lock.json",
"!**.DS_Store*",
"!Thumbs.db",
"!./gulpfile.babel.js",
"!./wpgulp.config.js",
"!./*.codekit3",
"!./.gitignore",
"!./style.scss",
"!./style.less",
"!./dist/"
])
.pipe(zip(config.textDomain + ".zip"))
.pipe(gulp.dest("./../"))
.pipe(
notify({
message: "\n\n✅ ===> ZIP — completed!\n",
onLast: true
})
);
});
/**
* Task: `child`.
*
* Creates a ZIP file with a child theme starter
*
*/
gulp.task("child", () => {
return gulp
.src([
"./inc/child-theme/functions.php",
"./inc/child-theme/style.css",
"./screenshot.png",
"!**.DS_Store*",
"!Thumbs.db",
"!./*.codekit3"
])
.pipe(zip(config.textDomain + "-child.zip"))
.pipe(gulp.dest("./../"))
.pipe(
notify({
message: "\n\n✅ ===> CHILD THEME — created!\n",
onLast: true
})
);
});
/**
* Task: `starter`.
*
* Creates a ZIP file with a new theme inside. Like a starter theme
*
* Command Example: npm run starter -- --name zeus
* Command Example: npm run starter -- --name black-label
*
*
*/
gulp.task("starter", () => {
return gulp
.src([
"./**/*",
"!./{node_modules,node_modules/**/*}",
"!**.DS_Store*",
"!Thumbs.db",
"!./*.codekit3"
])
.pipe(
replace(
changeCase.lowerCase(changeCase.snakeCase(config.textDomain)) +
"_",
changeCase.lowerCase(changeCase.snakeCase(params.name)) + "_"
)
)
.pipe(
replace(
changeCase.upperCase(changeCase.snakeCase(config.textDomain)) +
"_",
changeCase.upperCase(changeCase.snakeCase(params.name)) + "_"
)
)
.pipe(
replace(
changeCase.lowerCase(changeCase.paramCase(config.textDomain)) +
"-",
changeCase.lowerCase(changeCase.paramCase(params.name)) + "-"
)
)
.pipe(
replace(
changeCase.lowerCase(changeCase.snakeCase(config.textDomain)) +
".",
changeCase.lowerCase(changeCase.snakeCase(params.name)) + "."
)
)
.pipe(
replace(
changeCase.lowerCase(changeCase.snakeCase(config.textDomain)) +
" ",
changeCase.lowerCase(changeCase.snakeCase(params.name)) + " "
)
)
.pipe(
replace(
"'" + config.textDomain + "'",
"'" + changeCase.paramCase(params.name) + "'"
)
)
.pipe(
replace(
'"' + config.textDomain + '"',
'"' + changeCase.paramCase(params.name) + '"'
)
)
.pipe(
replace(
"/" + config.textDomain + "/",
"/" + changeCase.paramCase(params.name) + "/"
)
)
.pipe(
replace(
changeCase.titleCase(
changeCase.sentenceCase(config.textDomain)
),
changeCase.titleCase(changeCase.sentenceCase(params.name))
)
)
.pipe(zip(changeCase.paramCase(params.name) + ".zip"))
.pipe(gulp.dest("./../"))
.pipe(
notify({
message: "\n\n✅ ===> STARTER ZIP — completed!\n",
onLast: true
})
);
});
/**
* Task: `files-js`.
*
* Moves CSS files from node_modules
*
*/
gulp.task("files-js", () => {
var files = gulp
.src(["node_modules/bootstrap/dist/js/bootstrap.js"])
.pipe(gulp.dest(config.jsVendorFolder));
return merge(files).pipe(
notify({
message: "\n\n✅ ===> JS FILES moved from node_modules!\n",
onLast: true
})
);
});
/**
* Task: `files-css`.
*
* Moves CSS files from node_modules
*
*/
gulp.task("files-css", () => {
var bootstrap = gulp
.src(["node_modules/bootstrap/scss/**/*"])
.pipe(gulp.dest(config.styleVendorFolder + "bootstrap/"));
var fontawesome = gulp
.src([
"node_modules/@fortawesome/fontawesome-free/{webfonts,webfonts/*}",
"node_modules/@fortawesome/fontawesome-free/{scss,scss/*}"
])
.pipe(gulp.dest(config.styleVendorFolder + "fontawesome-free/"));
var quemalabs_font = gulp
.src([
"node_modules/quemalabs-font/{fonts,fonts/*}",
"node_modules/quemalabs-font/style.scss"
])
.pipe(gulp.dest(config.styleVendorFolder + "quemalabs-font/"));
return merge(bootstrap, fontawesome, quemalabs_font).pipe(
notify({
message: "\n\n✅ ===> CSS FILES moved from node_modules!\n",
onLast: true
})
);
});
/**
* Task: `files`.
*
* Moves all the necessary plugins from node_modules to the corresponding folder
*
* WordPress requieres that all minified files had their original unminified file.
*
* This task will run only once, if you want to run it
* again, do it with the command `gulp files`.
*
*/
gulp.task("files", gulp.parallel("files-js", "files-css"));
/**
* Task: `clean`.
*
* Clean Dist folder
*
* This task will run only once, if you want to run it
* again, do it with the command `gulp clean`.
*
*/
gulp.task("clean", () => {
return del("dist/**", { force: true });
});
/**
* Task: `build`.
*
* Prepare all to publish the Theme and creates a ZIP file
*/
gulp.task(
"build",
gulp.series(
"adminStyles",
"editorStyles",
"stylesBuild",
"vendorsJS",
"customJS",
"images",
"translate",
"stylesRTL",
"readmeMarkdown",
"moveFiles",
"zip",
"clean"
)
);