A
A
amorphine2016-07-04 22:13:37
gulp.js
amorphine, 2016-07-04 22:13:37

How can gulp extract the files declared in the "main" section of the bower.json file from node_modules?

There is a task to connect bxslider to the project, and for someone else's ideological reasons, I cannot use bower.
The bxslider is loaded via npm install, the js component is connected via browserify and has nothing to do with the question.
It is necessary to extract some files declared in bower.json via gulp:
"dist/jquery.bxslider.css",
"dist/images/bx_loader.gif",
"dist/images/controls.png"
And put them in the assets/dist/ folder bxslider. It seemed to me that the simplest solution was to do this:

gulp.task('bxslider', function(){
    var bower = mainBowerFiles({
        paths: {
            bowerDirectory: 'node_modules',
            //bowerrc: '.bowerrc',
            bowerJson: 'node_modules/bxslider/bower.json'
        },
        overrides: {
            bxslider: {
                main: [
                    '**/images/*',
                    '**/jquery.bxslider.css'
                ]
            }
        }
    });

    return gulp.src(bower)
        .pipe(gulp.dest('assets/dist/bxlider'));
});

If you install the package via bower install, this trick works (the paths are different, of course). I got the necessary files in various ways through options in mainBowerFiles() or by overriding it in the root bower.json.
However, I can't use bower install now, and extracting files from node_modules, I observe some kind of bug: without filters, the only file that I can get is jquery.js. That is, the bxslider dependency arrives without the files I need.
Please point out the error. Or, if I'm messing around with bower.json for a problem that can be solved in a less bumpy way, please advise on the best way to do it.

Answer the question

In order to leave comments, you need to log in

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question