Skip to main content
Ask A Question
You’re not receiving notifications from this thread.

How do I add minified JS files to the Rails Webpacker

Rails • Asked by Arjun Rajkumar

I am trying to add min.js files - and getting an error.

This works while adding a normal .js file:

- app/javascript/packs/calendar.js
alert('Calendar loaded')

-# app/views/calendars/index.html.erb
<%= javascript_pack_tag 'calendar' %>

The above code works. But when I try to add a min.js file it gives an error.
-# app/views/calendars/index.html.erb
<%= javascript_pack_tag 'calendar' %>
<%= javascript_pack_tag 'something.min' %>

Can anyone share what the process is for adding min.js files to view via Rails Webpacker?



ALso - I have added 'something.min' to the javascript/packs/something.min.js

I made a stupid mistake!

Can call minified JS files also with the same way.
So, instead of '<%= javascript_pack_tag 'something.min' %>' like I did before - I just have to use '<%= javascript_pack_tag 'something' %>' - and it runs.

Login or Create An Account to join the conversation.

Subscribe to the newsletter

Join 31,353+ developers who get early access to new screencasts, articles, guides, updates, and more.

    By clicking this button, you agree to the GoRails Terms of Service and Privacy Policy.

    More of a social being? We're also on Twitter and YouTube.