Symlink or copy files from bower component

I need a way to determine the files that I need from the bower component. In bower.json in the component, the files I need are not specified in the main setting. I would like to symbolize or copy files to another directory resources directory from the gazebo. I am using Grunt and I have not found anything that could help. I would like to somehow identify all the files via json .

Sorry if this is not quite a stop flow worthy, but I really desperately want to find something that exists, and not reinvent the wheel.

I found this code here , and I don't know how to use it. That would be perfect.

 "dependencies": { "font-awesome": ">= 3.2.1" }, "overrides": { "font-awesome": { "main": [ "css/font-awesome.min.css", "font/FontAwesome.otf", "font/fontawesome-webfont.eot", "font/fontawesome-webfont.svg", "font/fontawesome-webfont.ttf", "font/fontawesome-webfont.woff" ] } } 
+6
source share
3 answers

What I personally do and recommend, create a .bowerrc file with postinstall instructions in the project root to move the assets:

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

Take a look at grunt-bower-task . The documentation offers this for extended use:

At the moment, "Bower Package" = "its git repository." This means this package includes tests, licenses, etc. The Bower community is actively discussing this issue (GitHub issues # 46, # 88, in Google Groups). This is why you can find tools like blittle / bower-installer that inspired this project.

Well, if you want more than the "main" files in the directory. / lib, then "exportOverride" to 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 does the rest.

+4
source

I have successfully used bower-installer , which may be of interest to those who do not use Grunt.

The Awesome font needs an extra fight because the CSS file uses relative paths (like ../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"} ] } } } } 
+2
source

Source: https://habr.com/ru/post/955503/


All Articles