3 ms·
For people who are making the switch from Rails 5 to 6, or transitioning from Sprockets to Webpacker, I strongly urge you to bookmark what I consider to be the
by peteforde 7y ago
For people who are making the switch from Rails 5 to 6, or transitioning from Sprockets to Webpacker, I strongly urge you to bookmark what I consider to be the missing manual for everything that falls through the cracks:
https://gist.github.com/andyyou/834e82f5723fec9d2dc021fb7b819517 https://gist.github.com/andyyou/834e82f5723fec9d2dc021fb7b81...
My only complaint with v6 is that we didn't take the opportunity to make a clean break from the Asset Pipeline. I know that there are gems that would break etc. Luckily, the process moving CSS to Webpacker is made easy via this document.
Tips!
If you're using Sass, make sure you switch from sass-rails to sassc-rails.
Stimulus is an awesome solution for your JS needs. Don't even think about React again until you've at least considered the power of a well-cached backend fronted by a Stimulus + Turbolinks solution.
Try to get an early handle on the multiple ways that import can be used in your JS files. There are three different forms and they all have subtleties that can bite you:
import 'library'
import { x, y, z } from 'library'
import * as Library from 'library'
If your JS has require() directives, convert them to import directives. import is the future.
Finally, don't ever let anyone shame you out of using jQuery. jQuery rocks and is an incredibly powerful tool that still brings superpowers to the table. Anyone who suggests it's simply "bad" is not bringing good arguments to the table. (But when things get hairy, take a good look at Stimulus!)