Giter VIP home page Giter VIP logo

gulp-cozy's Introduction

gulp-cozy

Manage your gulp tasks in a cozier way.

npm version Build Status

Rationale

Ever found yourself digging into a gigantic monstrous Gulpfile with hundreds of functions and tasks scattered all around? Well I did and I can tell you it's not a great feeling...

This small module attempts to help with keeping yourself cozier (and happier!) when working with Gulp. In a way it tries to bring a bit of the Node philosophy (also known as "The Node way") into your Gulpfile.

Gulp-cozy in fact offers a very easy way to separate all your Gulp tasks into small modules organized inside a dedicated folder. Gulp-cozy will take care to load all the modules and to register them as Gulp tasks. With this approach you will end up with several small modules that serve one specific purpose (a task), which in turn result easier to maintain and to reason about.

Installation

npm install --save-dev gulp-cozy

Usage

Inside your Gulpfile:

#Gulpfile.js

var gulp = require('gulp');
var cozy = require('gulp-cozy');
cozy(gulp);

Then you need to create a gulp folder inside the root of your project. You will add all your tasks inside this folder. Every task is a file which name will represent the name of the gulp task. For example we can add the build-css task by creating the build-css.js file as follows:

#gulp/build-css.js

var concat = require('gulp-concat');
var minifyCss = require('gulp-minify-cssevery');

module.exports = function(gulp) {
  return function() {
    return gulp.src([
      './node_modules/bootstrap/dist/css/bootstrap.css'
    ])
      .pipe(concat('all.css'))
      .pipe(minifyCss({compatibility: 'ie8'}))
      .pipe(gulp.dest('./assets/'))
    ;
  }
}

Notice that the module exports a function that receives the current instance of Gulp as argument. This function is a factory for the real Gulp task logic so it should return a function which, will be executed when calling the build-css task with:

gulp build-css

You can also create a module to call a series tasks as in the following example.

#gulp/build.js

module.exports = ['clean', 'build-css', 'build-js', 'compress', 'upload'];

In this case the module needs to export just a plain array containing the names of the tasks to be invoked when running:

gulp build

Tests

npm test

Contributing

In lieu of a formal styleguide, take care to maintain the existing coding style. Add unit tests for any new or changed functionality. Lint and test your code. The project is currently using XO for styleguide and style checks run with the regular test suite.

You can report issues or suggest improvements on Github.

gulp-cozy's People

Contributors

lmammino avatar

Watchers

 avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.