How to ignore a specific javascript library for bower in gulp (possibly a regex problem)?

I use the plugin "main-bower-files" gulp. There is a huge library that is huge ... I want to ignore it on my list called "fatjslib.js". My current regular expression filter is as follows:

var listOfBower = mainBowerFiles({filter: (/.*\.js$/i)}); 

This brings up "fatjslib.js", and when I print the above variable, I see:

 "\\User\\kmichaels\\storage\\app\\bower_components\\fatjslib\FatJsLib\FatJsLib.js" 

How can I specify a filter or change the regex or do something so that "listOfBower" can ignore the file "FatJsLib.js"? I don’t want to specify the whole path, if possible, if there is a way of a wildcard to ignore anything, regardless of the structure of the path using FatJsLib, this may be better, 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 list of regular expressions or ignore it?

+6
source share
3 answers

One way the main-bower-files plugin stops reading a specific bower library is to pass the overrides option to param or set the overrides property to bower.json

METHOD 1: pass the override parameter:

Pass the overrides parameter to mainBowerFiles() and set the ignore property to true for the library you want to ignore.

 var listOfBower = mainBowerFiles({"overrides":{"fatjslib":{"ignore":true}}}); 

METHOD 2: Specify an override property in bower.json

You can also specify the overrides property in bower.json , and then there will be no need to pass an override parameter as a parameter. When the main-bower-files plugin reads the bower.json file, it will ignore the libraries that are specified in the property override with the ignore flag to true.

in bower.json add overrides property:

 "overrides": { "fatjslib": { "ignore": true } } 
+3
source

in case fatjslib contains several js files and you just want to ignore them and also include another, then you can override the main section of the package.

Each package comes with its own bower.json, which has a main section. This section contains the file to be inserted.

What you can do is override - override the main section to save the files you want to insert.

 "overrides": { "fatjslib": { "main": ["./dist/another-file.js"] } } 

and then provide these overrides mainBowerFiles

+2
source

How to change the regex as follows:

 /^(?!.*FatJsLib\.js$).*\.js$/i 

And to add additional libraries:

 /^(?!.*(?:FatJsLib|AnotherBigLib)\.js$).*\.js$/i 

Also, if you want to filter something with FatJsLib in your path, try:

 /^(?!.*\\(?:FatJsLib|AnotherBigLib)\\.*$).*\.js$/i 

Source: I wrote a regular expression, you can try it here . The main-bower-files documentation also states that the filter can use any regular expression .

0
source

All Articles