DEV Community

Muhammad Ans
Muhammad Ans

Posted on

Webpacker packs in rails 6 understanding

I am relatively new to rails and got stuck in webpacker entry points. Now I have worked with asset pipeline and thoroughly understand the concept of it. But When I started learning wepacker, I got little confused. The first issue is while referencing our javascript file while using asset pipeline, we use javascript_include_tag and give it a name. It can be application.js file or any other file name that is under app/assets/javascripts folder. And If it is nested in this folder as well, then we give it relative path which works. My issue is Webpacker has a concept of entry points which are in app/javascript/packs, we include it in our views or layout files by using javascript_pack_tag and give further the name of the pack. But If I have other files in this directory lets say I have app.javascript/custom/custom_js_file.js. How should I reference this in my view. When I try to reference this in my view using javascript_pack_tag 'custom/custom_js_file', it gets me manifest error that It can't find any entry points. How to resolve this issue. Should I create separate packs and include them in my packs or what?? This was my first question. My second Question is Asset pipeline does three things. Minification, Concatenation and pre-compilation pre-processing, Does Webpacker does the same ???

By the way, thank you for reading such a long discription.

Top comments (0)