Sharing Gulp tasks using an npm module

At Base we use Gulp as our tool to do run loads of tasks for us, including compiling Sass into CSS and Javascript into optimised code to make our web products leaner and faster. Many teams use different build tools, and our weapon of choice is Gulp.

Gulp runs on Node — If you haven’t used Gulp before, then check out this great tutorial for it.

All too often we’ve found ourselves repeating the same gulpfile.js across multiple projects, all doing the same thing in different places. You’ve got to them set up per project, and ensure all the dependencies are correct, then maintain the gulpfile. It’s one more overhead that gets in the way of writing great code.

We wanted to move our Gulpfile into a simple reusable module, using node. Surprisingly, it’s hard to find other people with the same problem — I stumbled across one StackOverflow thread and the pieces fell into place.

With this knowledge in the bag and some iterations, we made a base-gulp-framework npm package. This allows you to define a simple config and start building CSS and JS quickly so you can get on with the task of writing your code.

It’s been designed to take into account the differing complexity of projects, and you can always define your own Gulp tasks to override the ones in the framework. If you don’t want to build JS, then don’t include the JS config. Simple!

Your mileage will vary, and you may want to tweak the Gulp tasks to be shared across your own projects. But we feel the theory is sound — you are welcome to fork it for your own ends or use it on your projects. Drop some pull requests on GitHub if you think it can be improved.

This tool helps us build websites even faster for our customers, getting high quality transport websites into the hands of passengers in record time.

We’re always looking for ways to make our code open source where we can, because we know the benefits that sharing codes brings for everyone involved. We’re hiring for a Senior PHP Developer right now — join us and make some awesome stuff.