Configure bower to install only dist folder

18,882

Solution 1

What you're looking for is the ignore property in bower.json: https://github.com/bower/bower.json-spec

The developer of the module can use the ignore attribute to exclude files when the module is downloaded and installed through Bower.

If you are the developer of said module, you can use the ignore attribute to exclude everything but the dist folder.

If you're not the developer of the module, then there's not much you can do, you will get whatever the developer of the module has deemed significant. In most cases, this is not a problem.

Here's a typical configuration for the ignore attribute:

{
  "ignore": [
    "**/.*",
    "node_modules",
    "bower_components",
    "test",
    "package.json",
    "src"
  ]
}

Solution 2

Bower does not provide any option to do that. Mostly because they have refused to.

All we are left to is hacky ways to deal with it, like grunt-wiredep, which doesn't solve the problem in a strict sense.

Good luck!

Solution 3

From Bower's api documentation, there doesn't seem to be anything to say "Install just the dist folder".

As you are using Grunt already, you could probably create a task to run after your bower install using grunt-contrib-clean to remove unwanted files and folders from the bower_components folder.

Something like this should remove everything from the bower_components folder except dist folders:

clean : {
    dist : ['bower_components/*/*', '!bower_components/*/dist']
}

While looking into this I also found grunt-bower-task which seems to do exactly that. The only drawback I see to this method is that you have to create the bower.json by hand first and then run the grunt task.

Share:
18,882

Related videos on Youtube

Neve12ende12
Author by

Neve12ende12

Updated on September 16, 2022

Comments

  • Neve12ende12
    Neve12ende12 over 1 year

    I am trying to learn tools such as bower/grunt/requirejs in order to speed up the development process for my website and to make my code more modularized/efficient. I am currently following this tutorial. How does one make Bower only install the dist folder for my dependencies (setup in my component.json file) instead of the entire Git repository?