Avoiding unnecessary Gulp plugins

Avoiding unnecessary Gulp plugins

There are many cases where Gulp plugins are not necessary and can cause more problems than real benefits.

Let's take gulp-kss as an example. It is a convenience wrapper around kss-node and by using it Gulpfile will indeed look cleaner.

After quick and easy Gulp plugin install, everything works great and you tell to your colleagues how easy it was. After a while, you might have to take come back to your colleagues and tell it wasn't as easy it seemed.

Why isn't it good idea

The main problem is that npm package you originally intended to use becomes a dependency of Gulp plugin and therefore you're losing control. In the example of kss-node we can check package.json and see that it's using version selector ~0.4.0 for the kss-node. As I am writing this blog post the latest version is 2.1.0..

Author of the wrapper might be busy with something else, therefore, doesn't update wrapper's dependencies leaving you and your project with old dependency.

The wrapper plugin might also have other dependencies, those have dependencies and so forth. Take a look of visualization of (now deprecated) gulp-browserify dependencies.

The Gulp community has taken action to avoid unnecessary plugins. See the blacklist of plugins.

Getting rid of unnecessary plugin

In the case of KSS we could just run directly the CLI version of kss-node.

With gulp-shell:

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

var kssNode = 'node ' + __dirname + '/node_modules/kss/bin/kss-node ';

gulp.task('kss', shell.task(
  [kssNode + 'styles/ styleguide/ --template styleguide-template --mask *.scss']));

With gulp-run:

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

var kssNode = 'node ' + __dirname + '/node_modules/kss/bin/kss-node ';

gulp.task('kss', function () {
  run(kssNode + 'styles/ styleguide/ -- template styleguide-template --mask *.scss').exec();
});

Another example could be Browserify as it is a very popular package. Gulp-browserify was deprecated in favor of plain node implementation of Gulp task.

If you have examples where you have avoided using a wrapper plugin or if there is a case for wrapper plugin then let me know!