Neve12ende12
Neve12ende12

Reputation: 1194

Configure bower to install only dist folder

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?

Upvotes: 25

Views: 19325

Answers (4)

Ariel
Ariel

Reputation: 357

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!

Upvotes: 7

mummybot
mummybot

Reputation: 2788

This doesn't answer your question directly, but may help with what you are trying to accomplish.

There are two plugins: grunt-wiredep and grunt-wiredep-copy which can help you manage your bower dependencies. These automagically add the dependencies to your HTML, and can then grab the required minified ones and copy them to your dist folder.

I am however struggling with some aspects of this at How to manage bower dependencies when developing and deploying with grunt and a dist project folder?

Upvotes: 0

Ben
Ben

Reputation: 659

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.

Upvotes: 6

nwinkler
nwinkler

Reputation: 54457

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"
  ]
}

Upvotes: 22

Related Questions