Any equivalent gulp plugin for doing “grunt bower”?

有些话、适合烂在心里 提交于 2019-12-04 18:15:40

问题


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?


回答1:


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();
    });
});



回答2:


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 !");
    });
});


来源:https://stackoverflow.com/questions/24631744/any-equivalent-gulp-plugin-for-doing-grunt-bower

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!