Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Gulp - gulp-load-plugins not working

Gulpfile.js

installed via npm install --save-dev gulp-load-plugins

var gulp = require('gulp');

// Require all tasks in gulp/tasks, including subfolders
require('require-dir')('./gulp/tasks', {
 recurse: true
});

var $ = require('gulp-load-plugins')();
console.log($);

No matter where I declare it, the output will always be {}. I even tried with longer version having the options, still no luck

Using $.gulpif() gives

TypeError: Object #<Object> has no method 'gulpif'

I even downloaded few starter packs from github but still getting same output. I'm kicking myself for moving from Grunt.

like image 365
Dev Avatar asked Feb 06 '15 18:02

Dev


1 Answers

In the package.json, the plugin is saved as "gulp-if": "^1.2.5"

so, I had to change the code $.gulpif() to $.if() since the plugin will strip the names by below logic

var pattern = arrayify(options.pattern || ['gulp-*', 'gulp.*']);
var replaceString = options.replaceString || /^gulp(-|\.)/;
name.replace(replaceString, '');

A silly mistake which took 4 hours of my time.

P.S: I don't think it'll load any plugins without the prefix gulp in it's name.

like image 195
Dev Avatar answered Oct 20 '22 14:10

Dev