Reputation: 752
I'm trying to use font-awesome with npm but with the newest version (>4) I'm having difficulty finding the fonts
directory.
Before, I was using a npm script like cp -R ./node_modules/font-awesome/fonts/* dist/assets/
but this doesn't work anymore when my library is used by a program that will regroup all the modules at the root directory.
Is there a safe method to know where they are or any other trick that could achieve the same goal?
Thanks
Upvotes: 4
Views: 2446
Reputation: 108
I found a solution: I implemented an npm utility to output node_module's path https://github.com/lexoyo/node_modules-path
It just registers as a ".bin" script to be accessible in npm scripts, and the output is Path.resolve(__dirname, '..');
.
So you can use this in your package.json or shell scripts:
$ mkdir -p dist/fonts
$ cp -R `node_modules`/font-awesome/fonts/* dist/fonts/"
The script exports the NODE_MODULES
env var so you should be able to use it like this, but I did not test it:
$ mkdir -p dist/fonts
$ node_modules
$ cp -R ${NODE_MODULES}/font-awesome/fonts/* dist/fonts/"
Upvotes: 2