Exclude a folder from main-bower-files

2k Views Asked by At

How do I filter out an entire folder from the main-bower-files?

For example, if I'm doing this mainBowerFiles('**/jquery-validation/**'), it returns only the files from the jquery-validation folder, but I need the opposite.

I've tried mainBowerFiles('!**/jquery-validation/**'), however it seems like ! sign doesn't work in this case. What's wrong with my pattern?

2

There are 2 best solutions below

0
On BEST ANSWER

It is possible to ignore Bower Packages getting picked up by mainBowerFiles with adding overrides: PACKAGE_NAME to bower.json

{
    "name": "My Project",
    "description": "",
    ...
    ...
    ...
    "dependencies": {
        ...
        ...
        ...
    },
    "overrides": {
        "PACKAGE_NAME": {
            "ignore": true
        }
    }
}

https://github.com/ck86/main-bower-files#ignore

0
On

I solved this using filter function:

var ignoreJs = ['jquery-validation', ...];

// filter function
function mainBowerFilesFilter(filePath) {
    for (var i = 0; i < ignoreJs.length; i++) {
        if (filePath.indexOf(ignoreJs[i]) !== -1)
            return false;
    }
    return true;
}

// how to use
mainBowerFiles({ filter: mainBowerFilesFilter })