Symlink or copy files out of bower component Symlink or copy files out of bower component json json

Symlink or copy files out of bower component


What I personally do & recommend is create a .bowerrc file in your project root with postinstallinstructions to move assets:

{  "scripts": {    "postinstall": "mv ./bower_components/path/to/my.js ./path/to/ideal/location/my.js"  }}


Have a look at grunt-bower-task. The documentation suggests this, under advanced usage:

At this point of time "Bower package" = "its git repository". It means that package includes tests, licenses, etc. Bower's community actively discusses this issue (GitHub issues #46,#88, on Google Groups) That's why you can find such tools like blittle/bower-installer which inspired this project.

Okay, if you want more than "main" files in ./lib directory then put "exportsOverride" section into your bower.json:

{  "name": "simple-bower",  "version": "0.0.0",  "dependencies": {    "jquery": "~1.8.3",    "bootstrap-sass": "*",    "requirejs": "*"  },  "exportsOverride": {    "bootstrap-sass": {      "js": "js/*.js",      "scss": "lib/*.scss",      "img": "img/*.png"    },    "requirejs": {      "js": "require.js"    }  }}

grunt-bower-task will do the rest.


I've been using bower-installer with success, which might be of interest to those not using Grunt.

Font Awesome needed extra wrestling because the CSS file uses relative paths (e.g. ../fonts/).

{  "dependencies": {    ...  },  "install": {    "path": "webroot/components",    "sources": {      "font-awesome": {        "mapping": [          {"bower_components/font-awesome/css/font-awesome.css": "font-awesome.css"},          {"bower_components/font-awesome/fonts/fontawesome-webfont.eot": "../fonts/fontawesome-webfont.eot"},          {"bower_components/font-awesome/fonts/fontawesome-webfont.svg": "../fonts/fontawesome-webfont.svg"},          {"bower_components/font-awesome/fonts/fontawesome-webfont.ttf": "../fonts/fontawesome-webfont.ttf"},          {"bower_components/font-awesome/fonts/fontawesome-webfont.woff": "../fonts/fontawesome-webfont.woff"},          {"bower_components/font-awesome/fonts/FontAwesome.otf": "../fonts/FontAwesome.otf"}        ]      }    }  }}