When using Gulp WP Toolkit in your WordPress theme build you can concatenate and minify your JavaScript files easily. With some minimal configuration, the toolkit will concatenate your specified files and create an expanded version and a minified version.
This feature is useful if you have a global JavaScript file which you’d like to load everywhere, and then other JavaScript files for specific website features or pages (like a JS file which is specific to the account section of the website). Configuration should be set within toolkit.extendConfig() and with a js key. For example:
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
The default path for JS files to be output is /js within your theme directory. You can change this path by updating the dest configuration. For example, if you wanted your JS files to be output to assets/js your configuration should read:
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters