Replies: 2 comments
-
Are you open to individual (consulting) help from us at https://www.shakacode.com/ ? |
Beta Was this translation helpful? Give feedback.
-
Are those errors related to missing packs or something else?
Compiling once is a desired behaviour - we only recompile if the assets are stale and skip this to avoid slowness. Either way, we should compile everything so first page should already have all the assets pulled in and I wouldn't expect further recompiles to be needed unless source files change. I've tried to reproduce this with two pages, pulling different assets and no dev server running. First page runs compilation and spits out everything out in public/packs, second page skips compiling as all the assets are already there. Navigating back and forth between the two doesn't surface any problems. IIRC correctly, Webpacker had pretty similar flow. It only compiled again if the assets were deemed to be stale (ref https://github.com/rails/webpacker/blob/1cec8408d9c30e458c9f83b0c50ef53a255a4352/lib/webpacker/compiler.rb#L21-L45) If on Webpacker 5 you were facing compile on every page load then that suggests something not quite right with the setup as that would mean the compilation digest would not be recorded and/or watched paths kept changing with compilation. In Shakapacker, in development mode we don't use the digest strategy to check asset freshness. You can opt back into it by setting |
Beta Was this translation helpful? Give feedback.
-
I'm having an issue similar to this question on SO in that my Shakapacker development server is not consistently compiling assets.
I've recently upgraded my Rails 6.1.3 app from Webpacker to Shakapacker. Previously, with Webpacker, if I wasn't running the
webpack-dev-server
, my Rails server would show the "compiling..." message that it's compiling Webpack assets on every page that contains Webpack assets. Yes, it's slow, but it would compile.With Shakapacker, I see the "compiling..." message once, and it works great on a given page. However, if I navigate to a page like my dashboard, visit another page, then come back to the dashboard, it will not compile again, and my page will show a bunch of JavaScript errors.
Is there a way to get the behavior similar to Webpacker's? I'm having a lot of issues with my development server after upgrading, most notably that functions are not defined when the page loads, and I think I've finally narrowed down the issue to webpack asset compilation: it's just not happening like it used to.
I'd appreciate any advice, as I've been having a lot of struggles upgrading to Shakapacker.
Beta Was this translation helpful? Give feedback.
All reactions