How to prevent Bower from inflating my application?

I am working on a small web application using Express.js, Backbone.js, Bootstrap and some others. I decided to give Bower a try to manage the front-end components for this, but after installing the packages I noticed that they all installed a lot of things that I don’t need at all, such as LESS files (Bootstrap) or QUnit for the framework (Backbone), README.md files , source code documentation, etc .:

Bower madness

As you can see, this is absolute madness here.

I searched the package index a bit, and I found a leaner version of Bootstrap called bootstrap.css, but after installation I noticed that it still remains version 2.3.2, so it’s pretty out of date.

Is there no way to install updated dist versions of all these libraries?

The idea of ​​having a package manager is good, but it seems like it's a bit like my application source was bloating with all of this. I definitely don't need the Backbone documentation installed on my web server.

+6
source share
2 answers

This applies to package authors who do not configure their bower.json to ignore these extraneous files and folders. In addition, not all package authors configure their bower.json list of core files for their package.

You can see how without these two pieces of information - which files are not needed and which are the main files - Bower or any other tool cannot reliably guess what is needed and what is junk.

As for inflating your server; Ideally, you should not use Bower components. You will have a build process that takes source files, wherever they are on disk, and turns them into one miniature file.

+4
source

You can try bowercopy . What is he doing?

  • Download all bower components listed in bower.json
  • Copy files required for the specified folder
  • (Optional) Delete the bower_components folder.

Each time you run the bowercopy task, it performs this process above.

Grunt configuration example

  bowercopy: { options: { destPrefix:'app/jslib', // Here is the dest folder clean:true // It optinal }, dist: { // List all the files you need here src:'backbone/backbone.js' // "src" can be an array } } 

Yes, you need to specify all the files that you need one at a time. But he reaches your goal.

+1
source

All Articles