gulp Loading All The Plugins from Package.JSON


Example

Assuming , you have a grasp of how to install gulp, let us dive right down to requiring all the gulp- dependencies from package.json under your projects root folder.

In case you do not have a gulpfile yet , please create an empty file with the name

gulpfile.js

First , we require gulp. like so:

var $ = require('gulp');

Next up , let us load all our plugins, into our gulpfile , by the below snippet

Note

Please read through the comments in all of the snippets we will be including in this read, they provide more insight into every functionality

/*
require gulp-load-plugins, and call it
gulp-load-plugins will require individually,
all the plugins installed in package.json at the root directory
these required plugins, are lazy loaded
that is, gulp-load-plugins will only require them when they are referenced in this file
plugins are available for perusal, via camelcased names, minus gulp
eg: gulp-clean-css is accessed by $$.cleanCss
*/
var $$ = require('gulp-load-plugins')();

NOTE

Throughout the many examples we will have in the article , we alias

  1. gulp as $ and
  2. gulp-load-plugins as $$

purely for ease of typing.