Ognjen Regoje bio photo

Ognjen Regoje
But you can call me Oggy


I make things that run on the web (mostly).
More ABOUT me and my PROJECTS.

me@ognjen.io LinkedIn

How to get the direct path to a Webpacker pack

#rails #webpacker

If you are making use of a serviceworker to cache JS or CSS or you’re rendering some JS server-side you have to have the full path to the file.

If, at the same time, you’re using Webpacker to generate your assets, it’s not obvious how to get the full path to the pack

After some searching through the docs I found that it’s like this:

<%= Webpacker.manifest.lookup('application.js')%>

It seems that this API changed recently so most of the previous search results refer to the previous API. Hopefully this gets picked up and saves others from experimentation and googling that I had to go through.