Installing leafletjs and chartjs for phoenix 1.6

I’ve done a clean install of Phoenix 1.6 (as well as the latest & greatest for elixir/erlang) for a liveview application and I need to add chartjs and leafletjs to the project. Is there a guide (I can’t find anything on this) now that Phoenix uses esbuild. Or is this just a pure esbuild issue. I’ve spent more than enough time dealing with config issues for this project and i would like to move onto actually building the app. Any suggestions would be greatly appreciated.

What is the issue you are facing?

Are you importing leaflet and chartjs on your app.js file or any other file that is imported by it? Something like

import leaflet from 'leaflet'
import chartjs from 'chartjs'

then they will be available as these aliases

Have you read the section of the official Phoenix guides on using third party JS packages with esbuild?

Didn’t even see it. Thanks that’s what I needed.

1 Like