NPM package assets like fonts (font awesome)


#1

With CSS/Less importing issues in upcoming 1.3.2 resolved, what is the recommendation/best practice on dealing with assets like fonts. For example Font Awesome npm package require fonts in public/fonts.

The node way is to use a grunt/gulp/npm task/script to copy those, as explained here: http://stackoverflow.com/questions/21406538/how-to-use-font-awesome-icons-from-node-modules

But is there a more meteor way to dealing with those? Creating a symlink perhaps?


#2

You might want to add to the ongoing 6037 discussion with your font-awesome findings. As a workaround though I’d suggest staying away from symlinks. You could instead leverage npm’s scripts functionality to have the needed font files copied into your apps /public/fonts directory. Here’s an example showing how to make this happen after you run npm install:

...
"scripts": {
  "postinstall": "cp -R node_modules/font-awesome/fonts ./public/"
},
...

#3

Thanks for that. I didn’t want to highjack that thread with this as I thought it’s more of npm question rather than imports/less. I tried “postinstall” it is a great solution. My only concern is that in my case, Font awesome is a dependency of a bootrstap based theme I have developed, so to get to font-awesome dir I needed to do node_modules/my-theme/node_modules/font-awesome/fonts.

Could you suggest if there is a more robust way? Also what would happen if 2 packages depend on font-awesome and NPM installs font-awesome into root node_modules? There is no guarantee of where font-awesome will be located isn’t it?


#4

Hi,
try to setup meteor 1.3.2.4 and react
when just doing an import “/font-awesome/css/font-awesome.css”; in my jsx file i see when debugging in the browser there is a section in the indicating awesome as text/css style. (like bootstap) However the fonts are not found. Something wrong with path’s? I also see path indicating …/fonts, and read something about fa-font-path but don’t see a way out.