63

Bower's website describes the ignore key in bower.json:

ignore [array]: An array of paths not needed in production that you want Bower to ignore when installing your package.

Does this mean that it's ignoring paths in installed components, or in your package? Or something else? I was confused by this.

kaya3
  • 47,440
  • 4
  • 68
  • 97
Evan Hahn
  • 12,147
  • 9
  • 41
  • 59

3 Answers3

62

TL;DR:

ignore only works within the scope of packages being installed, ignoring matching patterns.


Somewhat longer answer:

Bower will ignore all files matching the patterns specified in the ignore property of bower.json in installed packages.

So, suppose if you ran bower install someBowerPackage which had following structure:

someBowerPackage
|- css/
|- js/
|- index.html
|- bower.json

with a bower.json file having:

{
  ...
  "ignore": [ "index.html" ]
}

then, index.html file of this someBowerPackage will not be installed within this package.

gustavohenke
  • 40,997
  • 14
  • 121
  • 129
  • 17
    So, just to be clear, `ignore` is only useful when creating your own bower package for distribution--it won't do anything if you're using bower to pull in dependencies? – mjs Feb 23 '14 at 15:26
  • 2
    I guess you meant the opposite. `ignore` will remove some paths from `mycomponent` when you run `bower install mycomponent`. – gustavohenke Feb 23 '14 at 16:28
  • 4
    I see this in the bower documentation, but for some reason it's not working for me. I still get all the files included in the 'ignore' array. I also cleared my local bower cache on the machine i'm running 'bower install' on :( – nomis Mar 12 '14 at 22:03
  • 2
    I tried the code above, but the ignore wouldn't work when the path was prefixed with `./` Example: I needed to alter `"./index.html"` to `"index.html"` and it then worked. Hopefully that helps someone reading this. – maxshelley Jan 20 '15 at 10:22
  • 1
    We have the problem, that we want to ignore the git history of our package which we host on a private git repository. The problem is, that the .git folder is 800mb big and the source we need is only 42mb. If we put ignore: [".git"] the git folder is not in the bower_components folder but bower update always fetches the whole repo. On the command we see: progress Receiving objects: 96% (6458/6675), 714.25 MiB | 20.19 MiB/s progress Receiving objects: 98% (6583/6675), 734.68 MiB | 20.22 MiB/s So every bower update takes a lot of time. – tschoartschi Feb 11 '15 at 13:53
  • @tschoartschi All that Bower does is `git clone` and `git checkout` a tag or branch. The `ignore` property is only used to _remove stuff after_ the package is installed. So I highly recommend you to move your source to another repository. – gustavohenke Feb 11 '15 at 16:29
27
  • ignore is related to the files in your package
  • You can't ignore on behalf of other packages
  • Dependencies are loaded all or none
uicoded
  • 617
  • 1
  • 9
  • 15
2

ignore values are only applied to packages fetched from a bower install endpoint by that component's bower.json file.
ignore values specified in project-root/bower.json have no effect on packages fetched as that project's components.

The bower.json Spec has been documented in its own github repo since this question was originally asked.

Ignore

Recommended
Type: Array of String

A list of files for Bower to ignore when installing your package.

Note: symbolic links will always be ignored. However bower.json will never be ignored.

The ignore rules follow the same rules specified in the gitignore pattern spec.

Files matching globs or file values in ignore will not be downloaded from an endpoint as part of the package.

remy-actual
  • 724
  • 7
  • 19