Deployment question

Showing 1-4 of 4 messages
Deployment question Russell Beattie 10/9/12 1:41 AM

I just tried out Bower and I had a question about the components directory - is it meant to be deployed into production directly? The documentation has an example of the .js files being linked directly within the components folder like <script src="components/jquery/jquery.js"></script>. So it seems like it.

But when I installed backbone.js, I was surprised to find the entire git repository within components/backbone/ in addition to cacheing the files in the ~/.bower directory as well. What I had assumed was that only the files listed within the "main" value in the component.json file would be copied inside the components dir. 

If in fact the components dir is meant to be deployed, this probably isn't a great idea - there could be examples, documentation, tutorials, PHP or Python scripts, etc. all which shouldn't be in there, if for no other reason that simple security concerns. 

But I might be misunderstanding how Bower should work. Should I have a 'deploy' step in my process which uses 'bower list --paths' to extract the right files and puts them into my project instead? If so, maybe a 'deploy' command might be a useful command to add, which simply copies the 'main' files to another directory for public deployment.

Thanks,

-Russ
Re: Deployment question Addy Osmani 10/9/12 2:34 AM
fwiw, in Yeoman we recommend that developers only link up to the Bower component files that they need so that these
are the only ones concat/minified as a part of your build process and thus the only things that should be deployed to production. You shouldn't be shipping any of the other content (eg a package's docs) to your site.

--
 
 



--

Addy Osmani

Developer Programs Engineer at Google
Blogger at: http://addyosmani.com
Phone: +44 7771 334170

Re: Deployment question Russell Beattie 10/11/12 1:35 PM

Hey Addy,

Thanks for the response. I just sat down with my project again and decided to try out Yeoman. I guess by "link up" you mean edit the Grunt.js file to only include the files you need? Just testing Yeoman now, I started a project using the basic init settings, then installed Backbone. Then I did a "yeoman build" and sure enough, *everything* from the backbone and underscore components directory went into the dist directory. So I'll have to go back and figure out which files I actually need and then edit the build to make sure only the files I need are copied over. This doesn't seem optimal to me - in fact it might be more work than not using Yeoman/Bower at all.

I also just noticed the Bower commit message from a few days ago clarifying that the main array should only contain one file per filetype - I'm not sure why, but what it means is that this parameter can't be used as a list of required files (think of Bootstrap which contains style sheets, images and maybe even plugins). 

I think it's pretty clear that Bower needs a "files" array inside the components.json to list out required package files and/or folders, similar to how NPM works. The install process could then cache the entire .git repository in the ~/.bower directory like it does now, but only copy the specifically listed package files to the install components dir.

-Russ
Re: Deployment question Adam Alexander 10/12/12 5:07 AM
For reference, https://github.com/twitter/bower/issues/46 contains a similar discussion.

--