I am using the "main-bower-files" gulp plugin. There is a bower library that is huge... I want to ignore it in my list called "fatjslib.js". My current regex filter is as follows:
var listOfBower = mainBowerFiles({filter: (/.*\.js$/i)});
This picks up "fatjslib.js" and when I print out the above variable, I see:
"\\User\\kmichaels\\storage\\app\\bower_components\\fatjslib\FatJsLib\FatJsLib.js"
How can I specify the filter or change regex, or do something such that the "listOfBower" can ignore the "FatJsLib.js" file? I don't want to specify the whole path if possible, if there is a way to wildcard ignore anything regardless of pathstructure with "FatJsLib", that may be best, but I am open to suggestions. Is the solution flexible to add "AnotherBigLib.js" (should there be a second library under some path structure) to the regex or ignore list?
One way for the "main-bower-files" plugin to stop reading specific bower library is to pass the overrides option in the param or to set the overrides property in bower.json
METHOD 1: To pass the overrides param:
Pass the overrides
option to the mainBowerFiles()
and set the ignore
property to true
for the library you wish to ignore.
var listOfBower = mainBowerFiles({"overrides":{"fatjslib":{"ignore":true}}});
METHOD 2: Specify overrides property in bower.json
You can also specify overrides property in bower.json
and then there will be no need to pass overrides option as a param. When main-bower-files
plugin will read the bower.json file, it will ignore the libraries that are set in overrides property with ignore flag to true.
in bower.json add an overrides
property:
"overrides": {
"fatjslib": {
"ignore": true
}
}
in case fatjslib
contains multiple js files, and you just want to ignore one while as include another, then you can override main section of the package.
Every package comes with its own bower.json which has a main section. This section contains the file to be injected.
What you can do is, in overrides - override the main section just to keep the files you want to be injected
"overrides": {
"fatjslib": {
"main": ["./dist/another-file.js"]
}
}
and then provide these overrides to mainBowerFiles
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With