How to copy fonts folder from node_module using Brunch?

I just followed http://cloudless.studio/articles/4-installing-font-awesome-from-npm-in-phoenix to add FontAwesome but it doesn’t seem like brunch is copying the fonts.

No route found for GET /fonts/fontawesome-webfont.woff

Some steps to debug this would be appreciated!

2 Likes

When I put /^(node_modules\/font-awesome)/ inside paths.watched it only includes the css files. Seems like a bug in Brunch…

1 Like

That is because ‘watched’ things only watch for files of which there are plugins for, which is generally just js, css, and html (templates). You probably want to add that path as an ‘asset’ directory and that ‘might’ work. What would work fine though is to make a brunch plugin that you can specify font paths into and it can copy the files over to the final static directory. I’ve been writing a few brunch plugins lately so I might be able to do soon (probably weekend) if you remind me enough? :slight_smile:

2 Likes

Also do note, the ‘usual’ way of handling fonts is having an npm task (in the package.json file) that copies them from the npm module you depended on into your own work tree directly. That is what I do, although I do not like it, I would prefer a plugin too…

1 Like

you could try

1 Like

@OvermindDL1 I also have it inside conventions.assets as well but it’s not working. Our default /^(web\/static\/assets)/ works fine though…

God… Don't categorize node_modules as 'assets' even if they match the regexp
https://github.com/brunch/brunch/blob/41f0c1f298bf94024621457c66caee74ea6d4ddc/CHANGELOG.md#brunch-26-apr-2-2016

Lol, must be a reason for that. :stuck_out_tongue_winking_eye:

Ah, yeah, that looks like it would work! ^.^

@OvermindDL1 I followed your advice and added postinstall": "cp -R node_modules/font-awesome/fonts web/static/assets" to npm scripts.

I also opened an issue on github since you can’t even override this changed behavior. https://github.com/brunch/brunch/issues/1514

2 Likes