How to specify directory where bower will place the dependencies?

0

I installed here on my machine bower globally.

npm install -g bower

Then when I use the command bower install jquery , it installs it in the folder named bower_components .

Is there any way to get bower to install in a specific directory?

I want to install right in the public/js/ directory of my project.

    
asked by anonymous 03.02.2016 / 14:44

3 answers

5

Use --config.cwd=[path] , example:

bower install jquery --config.cwd=/home/brunorb/test
# /home/brunorb/test/bower_components/jquery/

Note that it still creates the bower_components folder within the specified dir.

Another option is to use a .bowerrc file and set the dir on key directory as shown here >.

    
03.02.2016 / 14:59
3

Create a file within the project root named .bowerrc with the following content:

{
  "directory": "/novo/local/das/dependencias"
}
    
28.08.2016 / 16:37
1

I believe that the forms presented above are good, but if you have the need to manage your dependencies by specifying the folders, however, each folder is in a specific folder according to the type of the script (css in a folder, and javascript in another), you can use bower-installer .

To install it you simply run:

npm install -g bower-installer

After this, you must set the bower.json , the "path" value within install , specifying the installation folders for each file extension.

See:

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

The "sources" attribute defines which files you want to install in the specified directories.

Then, after this setting, just run the command:

 bower-installer

I'm using it and I think it's very efficient.

    
30.08.2016 / 14:16