Closed igrigorik closed 4 years ago
I am surprised you got that far with Sprockets > 3.7... I always downgrade from 4+ as that was always screwing with webpack and assets. But that is probably neither here nor there. I also saw the same problem too, where my mickey mouse tiny CSS payload from Polaris would trigger that warning about my assets of 20kb exceeding limits --- hahaha...
Wish I knew the secret sauce to get you over that hump. I have > 20 Apps on Rails 6.0.3 plus Polaris working fine at Heroku... but for the life of me, it is always a roll of the dice to produce a perfect package that actually runs as there are 2,456,321 moving parts in JS of which I wrote exactly none.
@resistorsoftware ah, joy.. thanks for chiming in.
Can you share more details on your typical downgraded setup? Are you locking sprockets
at ~>3.7, or do you also downgrade other dependencies? I tried gem "sprockets", "~> 3.7.0"
in my Gemfile, but that didn't seem to yield any benefit.
sprockets (3.7.2)
concurrent-ruby (~> 1.0)
rack (> 1, < 3)
sprockets-rails (3.2.1)
actionpack (>= 4.0)
activesupport (>= 4.0)
sprockets (>= 3.0.0)
First off. I use rails new to generate an app with Webpacker and in my case, React so that I can deal with Polaris. Once that is done, I use the generators to install Shopify App and establish the basics. At this point, I am where you are, and it all just works.
Things I do different? I blow away the Shopify React codes, and use my own. I get Polaris via a slightly different approach, but nonetheless, the same. I use App Bridge, and all that jazz. I am not sure how I could show you without going through the whole rigamarole of setting up a complete demo.
I do not use React Rails. Not sure that that gem is a good one. Maybe it is... I just never use it.
So you followed that pattern? I am not sure my custom React approach would make a stitch of difference. I never use ERB I still use Haml and for me, I prefer to bring the App to life with a template slightly different than Shopify... it cannot be that makes webpacker assets work or not. Has to be Sprockets or something.
Aha, thank you sir. Your point about react-rails and webpacker config tipped me in the right direction: resolved in https://github.com/igrigorik/shopify-core-web-vitals/commit/27910d51a5c54b79d95fb09f19873aa9efb13cb5.
FWIW, I flipped back to latest sprockets and, so far at least, things seem to be working a-ok. To your point though, I'm not exercising much of react-rails machinery, so that's probably more a liability than a feature. But for now, it works.
I suppose I keep sprockets down and out as I never use it, and it was causing errors at v4 with asset calls. Like Turbolinks. Some things in Rails seem only fit for DHH and his Apps, or for really advanced and complex Apps. My use cases for Shopify Apps never seemingly need much more than a basic API on my end to hit my DB and return some JSON, along with the standard XHR + CSS we all know and love since 1998 or so... so I am getting better at removing more Rails than keeping it. Unfortunately, webpack, yarn and node now more than make for headaches with their endless versions of minuscule LOC chained together to make the creaky JS web go.
Are there any special considerations or requirements for deployment & build on Heroku?
I have an app running locally and webpacker is doing all the right things, with both JS and CSS coming through correctly, but when I push the same code to Heroku the JS is there (elements are responsive) but it looks like Polaris styles are missing -- also, I don't see any failed requests. Would really appreciate any tips, and apologies upfront if it's a misconfiguration on this end, since I've been running in circles on this one for well over and hour.
The app:
Heroku build output...