Task Runners (Grunt)

Similarly to how Composer supports scripts to create shortcuts or outright automations for different tasks, something similar can be done within the npm ecosystem. Specifically, we are talking about task runners like Grunt and Gulp.

The DWS WP Framework uses Grunt to automate certain tasks. For example, some modules use Grunt tasks to automatically generate the POT file by scanning the code for translatable strings.

The example plugin has Grunt tasks pre-written for compiling TypeScript and Sass assets and performing other post-optimizations to the compiled files. All of this is powered by npm packages listed in the packages.json file together with the configuration written in the project's Gruntfile.

Most of these tasks can also be handled by Composer scripts, but npm provides some easy-to-use packages that were built out for these tasks. It just makes more sense to use JavaScript instead of PHP.

The purpose of this documentation is not to teach you how to use task runners, but we strongly encourage you learn how to use them. It's pretty simple really and they can automate some pretty difficult tasks.

Last updated