Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Install Bower components into two different directories?

When using CSS and JS components, is it possible, or even, does it make sense to install them to different directories?

. |-- app     |-- scripts         |-- components           # js components go here             |-- backbone-amd             |-- etc     |-- styles         |-- modules         |-- partials         |-- components           # sass components go here             |-- normalize.scss             |-- etc 

What's the most efficient way to structure a project organized as such? Is there a good Grunt task to accomplish the goal of integrating bower installed sass components for a development environment?

like image 721
Robb Schiller Avatar asked Apr 16 '13 16:04

Robb Schiller


People also ask

Where does Bower install packages?

Installed packages will be placed in a bower_components directory. This is created in the folder which the bower program was executed. You can change this destination using the configuration options in a . bowerrc file.

What is Bower components?

Bower is a package manager for client-side libraries and components that contain HTML, CSS, JavaScript, fonts, image files, and so on. You can install, locate, upgrade, and remove Bower packages without leaving WebStorm, on the dedicated Bower page or from the command line in the built-in terminal.

What is Bower and npm?

Bower is a package manager, like npm, which manages frameworks, libraries, assets, and utilities, installs them, and makes sure they are up to date. Traditionally, many web development projects combined npm and Bower. npm was used to manage back-end dependencies, while Bower was used for front-end dependencies.


2 Answers

Bower needs to keep track of every component you install. That would be very hard if they were split up in multiple locations. For Sass development, just put the components folder in the Sass search path.


There are grunt tasks that can assist you in splitting it up if you insist on doing that:

(though not recommended)

  • grunt-bower-task
  • grunt-bower-organiser
  • grunt-bower
like image 181
Sindre Sorhus Avatar answered Sep 21 '22 07:09

Sindre Sorhus


There is a node package called bower-installer that provides a single command for managing alternate install paths.

run npm install -g bower-installer

Set up your bower.json

{   "name" : "test",   "version": "0.1",   "dependencies" : {     "jquery-ui" : "latest"   },   "install" : {     "path" : {       "css": "src/css",       "js": "src/js"     },     "sources" : {       "jquery-ui" : [         "components/jquery-ui/ui/jquery-ui.custom.js",         "components/jquery-ui/themes/start/jquery-ui.css"       ]     }   } } 

Then run bower-installer command.

This will install components/jquery-ui/themes/start/jquery-ui.css to ./src/css, etc

like image 44
lfender6445 Avatar answered Sep 23 '22 07:09

lfender6445