Skip to main content

Frontend build tool with PostCSS and Gulp

Frontend build tools can save a lot of valuable time and make a frontend developers life much easier. They can do almost anything: download libraries, run tests, bundle packages, automatize tasks, and so much more. Lately, PostCSS and Gulp v4 are the talks of the town when it comes to the frontend side of web development. To ride this wave, we've built a frontend build tool coupling PostCSS and Gulp. This frontend build too essentially helps with frontend tasks such as compiling, linting & image optimization. Let's dive into how we built this frontend build tool! 

What is PostCSS?

PostCSS is a tool that gives access to a bunch of CSS related plugins to help improve the workflow and writing CSS. This enables a developer to start with a blank slate and select the additional plugins as required. If you are familiar with JavaScript tooling, then you can think of PostCSS as Babel for CSS.

What is Gulp?

Gulp is a JavaScript toolkit that helps in implementing multiple front end tasks during web development. Gulp is one of the most popular build tools that help with several tasks when it comes to web development.

Pre-requisites for using the tool

Ensure that you are using the latest LTS release of Node.js. Start by installing and running Node.js. 

To install the required packages, use

Now that the pre-requisites are in order, let’s take a look at some of the features of this tool categorized by the front-end tasks.

Features and functionalities of our frontend build tool

Script for CSS

Script for JavaScript

Our frontend build tool uses ES6 for managing javascript with the 'Drupal.behaviors' code standard.

Linting JS and CSS

Linting Javascript and CSS files along with fixing Linting errors & formatting.

Script to lint JS:

Script to fix JavaScript errors & format JS file:

Script to lint CSS:

Script to fix CSS linting errors:

Image optimization

The images designated for the custom theme can be placed in the images/ folder. We have a gulp task to optimize images.

Run multiple tasks

Run multiple tasks at one time. Like build/compile CSS, JS & optimise images.

Continuous file watch:

OR

Conclusion 

Our frontend build tool makes frontend developers life easier by assisting in frontend tasks such as compiling, linting & image optimization. Check out our frontend build tool here - gulp-postcss.

Thank you for reading!

We'd love to talk about your business objectives

Written by