Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Configure bower to install only dist folder

Tags:

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?

like image 320
Neve12ende12 Avatar asked Feb 19 '15 23:02

Neve12ende12


3 Answers

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"   ] } 
like image 139
nwinkler Avatar answered Oct 08 '22 14:10

nwinkler


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!

like image 40
Ariel Avatar answered Oct 08 '22 14:10

Ariel


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.

like image 43
Ben Avatar answered Oct 08 '22 13:10

Ben