Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Any equivalent gulp plugin for doing "grunt bower"?

With grunt, I could use command grunt bower (provided by grunt-bower-requirejs) to auto-generate RequireJS config file for my local bower components.

Is there any plugin for gulp to perform similar task?

like image 623
huocp Avatar asked Jul 08 '14 12:07

huocp


Video Answer


2 Answers

UPDATE: for future readers, please look at the correct answer from @user2326971

Solved it by hook up gulp directly with node module bower-requirejs

npm install bower-requirejs --save-dev

In gulpfile.js

var bowerRequireJS = require('bower-requirejs');

gulp.task('bower', function() {
    var options = {
        baseUrl: 'src',
        config: 'src/app/require.config.js',
        transitive: true
    };

    bowerRequireJS(options, function (rjsConfigFromBower) {
        console.log("Updated src/app/require.config.js !");
    });
});
like image 169
huocp Avatar answered Sep 20 '22 01:09

huocp


Mind that bowerRequireJS is an asynchronous function. So you would need to use a callback (or synchronously return a Promise) to mark that task as asynchronous like so:

gulp.task('bower', function(callback) {
    var options = {
        baseUrl: 'src',
        config: 'src/app/require.config.js',
        transitive: true
    };

    bowerRequireJS(options, function (rjsConfigFromBower) {
        callback();
    });
});
like image 35
Soeren Avatar answered Sep 19 '22 01:09

Soeren