Contact
Site: US UK AU |
Nexcess Blog

WPGulp Is A Great Introduction To Using Gulp For WordPress Theme And Plugin Development

May 12, 2016 0 Comments RSS Feed

WPGulpOver the last few years, web development toolchains have grown increasingly complex. It wasn’t all that long ago that web pages were coded in HTML and CSS in a text editor. But, with the introduction of CSS pre- and post-processors, template languages, greater demand for site optimization, and the plethora of other helpful little tools that aid web development— including WordPress theme development — it’s become increasingly difficult to set up and manage development environments.

No one wants to have to run a SASS compiler every time they make a change to their site or theme, still less concatenate, minify, and compress CSS and JavaScript whenever they push to a production server.

Gulp is a task runner that helps developers automate this sort of job. The principle is simple — Gulp watches a group of files, and when it detects that they’ve changed, it runs a series of tasks which will take the files and pass them through various filters. So, when you save your SASS files, Gulp notices and runs a task that passes them through the SASS compiler and drops the resulting CSS file in the right place.

There are three important things to understand about Gulp.

  • It’s a Node.js application, which means you have to have Node installed on your machine for it to work.
  • It values code over configuration. Gulp tasks are written in JavaScript in a file called gulpfile.js. If you know even basic JavaScript, getting up and running with Gulp shouldn’t be a problem.
  • Gulp uses a pipes metaphor. Gulp tasks can be thought of as a series of pipes through which files are sent, which makes it possible to chain together multiple tools, much as you can on the Linux command line. You might create a “styles” task which takes SASS files, runs them through the SASS preprocessor and outputs CSS, which is then piped through Autoprefixer, which adds CSS prefixes as necessary, the results of which are then piped through a minification tool, and so on.

If you want a thorough introduction to using Gulp with WordPress, take a look at this excellent article from Ahmed Awais.

To make things a little easier on WordPress developers who want to get started with Gulp, Awais has also created WPGulp, a boilerplate that includes the basics theme and plugin developers need to setup a working Gulp environment.

In combination with Awais’ introductory blog article, which runs through how to install Gulp, use it with WordPress, and includes a thorough explanation of the gulpfile.js file, WPGulp is an excellent primer for getting started with Gulp in your WordPress development projects.

WPGulp is by no means a comprehensive framework for integrating Gulp into WordPress development workflows, but it contains more than enough that any competent developer will be able to pick up the ball and run with it.

Posted in: WordPress