A
A
AlexRas2016-12-02 14:17:56
JavaScript
AlexRas, 2016-12-02 14:17:56

How to organize library files into folders in gulp using main-bower-files?

Hello, tell me how you can decompose library files into their folders, for example:
If you use such a task, then all files will fall into one lib folder

gulp.task('bower', function() {
    gulp.src(mainBowerFiles({
            "overrides": {
                "jquery": {
                    "main": "./dist/jquery.min.js"
                },
                "bootstrap-grid": {
                    "main": [
                        './dist/bootstrap-grid.min.css'
                    ]
                }
            }
        }))
        .pipe(gulp.dest('./lib/'))
});

How to make the files fall into their folders, i.e.:
lib
- jquery
-- jquery.min.js
- bootstrap-grid
-- bootstrap-grid.min.css

Answer the question

In order to leave comments, you need to log in

1 answer(s)
A
AlexRas, 2016-12-02
@AlexRas

I did it, does anyone have a better option?

gulp.task('bower', function() {
    var mainBowerFilesArr = mainBowerFiles({
            'overrides': {
                'jquery': {
                    'main': './dist/jquery.min.js'
                },
                'bootstrap-grid': {
                    'main': './dist/bootstrap-grid.min.css'
                }
            }
        }).map( function(path) {
            return path;
        });

    for (var i = mainBowerFilesArr.length - 1; i >= 0; i--) {
        var p = mainBowerFilesArr[i].substring(mainBowerFilesArr[i].indexOf('bower_components'));
        var f = p.split('\\')[1]+'/';
        gulp.src(p).pipe(gulp.dest(path.build.lib+f));
    }
});

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question