hq1
How to include FontAwesome in Phoenix app?
Hi,
I am completely clueless when it comes to the whole static assets building pipeline. That’s probably the most overwhelming programming experience in my career thus far ![]()
Seriously though, can anyone please share a snippet of things I need to add to have FontAwesome icons available in a phoenix app?
I’m using Phoenix 1.4.0 so I guess that’s webpack then, plus I do npm install in assets directory to get the priv contents built. Everything is pretty much at mix phx.new defaults. Pls send halp.
Trending in Questions
I’m in search of an Elixir library that offers PDF generation capabilities similar to Ruby’s Prawn. While there have been discussions abo...
New
I’m looking to build a personal workflow to quickly deploy web applications written in elixir/phoenix, for local consumption (ie not on t...
New
Using Phoenix.LiveView.TagEngine as an EEx.Engine is deprecated!
To compile HEEx, use Phoenix.LiveView.TagEngine.compile/2 instead.
Sta...
New
Hello !
We want new/edit form pages to POST/PUT to their own URL rather than the resources REST defaults (post /things, put /things/:id)...
New
Before I dive in myself, did anyone successfully sprinkle Hologram into their existing LiveView app?
Looking for hints regarding:
Addi...
New
Hi all, I wanted to ask how the community is dealing with post-release steps.
Today we have Ecto migrations, which make sure that the db...
New
I am using Oban and occasionally, shortly after a deployment, a handful of jobs can fail because of dependency on other parts of the syst...
New
Other Trending Topics
Hey, I’m Jesse and I’m the main contributor behind Dexter, a full-featured, lightning-fast Elixir LSP optimized for large codebases. It s...
New
Beam Bots (or just BB for short) is a framework for building fault-tolerant robotics applications in Elixir using familiar OTP patterns. ...
New
Hello everyone. After busy few months I am happy to announce v0.1.0 of Emerge & Solve.
They are GUI (Emerge) and State management (S...
New
Emily is an Elixir library that runs Nx computations on Apple’s MLX. Install it as the default Nx backend and Nx, defn, Axon, Nx.Serving,...
New
I just stumbled on a newly redesigned elixir-lang.org. :tada: It looks like @Software_Mansion did the work, and I think it is generally a...
New
@hugobarauna and I (Alex Koutmos) have been hard at work on writing a book on Nerves that takes you from simply blinking LEDs to building...
New
Categories:
Sub Categories:
Forums
Popular Tags
- #ecto
- #liveview
- #troubleshooting
- #learning-elixir
- #deployment
- #library
- #erlang
- #testing
- #genserver
- #mix
- #absinthe
- #remote-other
- #otp
- #plug
- #how-to-question
- #macros
- #postgres
- #channels
- #elixirconf
- #exunit
- #discussion
- #code-sync
- #javascript
- #podcasts
- #onsite
- #dialyzer
- #docker
- #authentication
- #umbrella
- #full-time-contract
- #podcasts-by-brainlid
- #ecto-query
- #elixir-ls
- #phoenix_html
- #iex
- #blog-post
- #graphql
- #genstage
- #ai
- #elixirconf-us
- #websockets
- #supervisor
- #advent-of-code
- #distillery
- #processes
- #api
- #forms
- #metaprogramming
- #performance
- #security











First 10 of 16 Posts
hauleth
You enter
assetsdirectory and then follow NPM instructions. That is it. Phoenix assets pipeline is exactly the same way as any other webpack project with specific build directory (../priv/static) and that is all.adrianrl
Hi, when it comes to icons, fonts or heavy dependencies it’s a good idea to serve those assets using their respective CDNs, so I’d rather add a simple
linktag to include Font Awesome. You should only serve by yourself those dependencies that you want to customize.hq1
I wish. Nothing related to font awesome ends up in
priv/staticafter doing just that.“Same way as any other webpack project” means nothing to me unfortunately.
hq1
That makes sense, I’ll see if I can just put those pre-built assets on S3 due to privacy concerns.
hauleth
Have you restarted your application? It need to be rebuilt after the fact.
MrDoops
You might need something like File Loader to manage the kinds of assets FontAwesome provides. This guide seems to go over using Font Awesome and File Loader.
kokolegorille
I have this loader for fonts in my webpack.config.js, in the modules/rules section
Then in app.js, I load app.scss, and in app.scss, I load fontawesome, something like this…
But for this to work, I added following dev dependencies,
You might show your webpack.config.js, and your package.json.
eahanson
Another option is to download individual font awesome icons as SVGs into
assets/static/imagesand them emit them in your templates or views with Phoenix Inline SVG.If you only want a few icons, this can reduce the size of your responses and doesn’t involve any webpack stuff. Caveats: some older browsers have issues with SVG, and every time you want a new icon, you have to download it and add it to your assets directory.
hq1
Thank you, that worked!
belgoros
Navigate to your phoenix app assets directory:
Install free edition of fontawesome as explained here:
You will see
package.jsonupdated with a new entry:You will have to install
file-loaderpackage as well:npm install file-loader.Then modify
webpack.config.jsto be able to copy awesome fonts and extract SCSS files:Next, modify your
app.scssfile as follows (I also use Bootrstrap, so remove the related import if you don’t use it):And finally, my
_custom.scssfile (remove$primarycontaining line, it is for Bootrstap override):Hope, this helps.