A guide for Webpacker?

46 views
Skip to first unread message

Josh Goodall

unread,
Aug 27, 2019, 1:09:38 AM8/27/19
to Ruby on Rails: Core
Despite my protestations I'm seen as A Rails Expert within my organisation. And I've been fielding a ton of questions re. JS asset management, due to the switch to Webpacker.

Webpack is tremendously powerful and Webpacker is a helpful manager and wrapper. However, Webpack itself is also a Heath Robinson machine and trying to configure/debug it in many common cases immediately becomes a voyage into the arcane.

Neither of these Rails Guides currently make any mention of Webpack or Webpacker:
The Asset Pipeline - https://guides.rubyonrails.org/asset_pipeline.html
Working with JavaScript in Rails - https://guides.rubyonrails.org/working_with_javascript_in_rails.html

I don't think it's unreasonable to suggest that they should both deal with relevant aspects.

The 6.0 upgrade guide (https://edgeguides.rubyonrails.org/upgrading_ruby_on_rails.html#using-webpacker) makes it seem that an upgrade is as simple as adding a gem and running a task, but for many existing applications it will be very far from trivial.

None of this is meant to detract from what's already there - the Webpacker gem itself has many useful docs and a pretty good README, but they're mostly written from a different perspective to that of a _guide_.  In particular there's often assumption of familiarity with Webpack, and many docs are thorough references rather than introductory guides.

For all I know there may be a new guide in progress, but I couldn't see a PR or issue. It's something I'd be interested in at contributing to, if only for the selfish reason of reducing my own burden.


--
Josh

Jake Niemiec

unread,
Aug 27, 2019, 6:48:32 PM8/27/19
to rubyonra...@googlegroups.com
Hello Josh, I'm from the webpack side of the equation.

> It's something I'd be interested in at contributing to, if only for the selfish reason of reducing my own burden.

A PR would greatly be appreciated! Here are some off-the-cuff topics that I see coming up often on the issue tracker: 
  • "I already know what my webpack.js exports need to be, how do I convert that to webpackER?"
  • "Webpacker comes with node sass but I need to use dart sass"
  • ⭐️ How package.json (unintuitively) acts differently than a gemfile (and how it can ruin your day)
  • "I need to use webpack-dev-server to deploy my stuff" (don't do this)
  • ⭐️Misunderstandings about what should be in a "pack". Users who make every individual js file a new pack will find that every pack can come at an expediential cost performance/size/buildtime depending on how much library code is duplicated.  
  • How does json/data from server to packed js 
  • NODE_ENV vs RAILS_ENV
  • When to use a file.js.erb and when to use a filePack.js (and how those communicate with each other)
  • There are times where you need to ignore install instructions from JS library READMEs
Hope this is helpful for a potential guide. If you have any questions feel free to email.

--
You received this message because you are subscribed to the Google Groups "Ruby on Rails: Core" group.
To unsubscribe from this group and stop receiving emails from it, send an email to rubyonrails-co...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/rubyonrails-core/193994bf-321b-451e-b4bb-2a4f1d23771b%40googlegroups.com.


--
WarmlyYours
Jake Niemiec
P: (800) 875-5285F: (800) 408-1100
Tell us how we're doing and receive $25 off your next order
 
Reply all
Reply to author
Forward
0 new messages