Replies: 2 comments 2 replies
-
Update: I found that nesting these in an "on document loaded" function (like below) solves the issue. I don't think this will be an issue on production since assets will have been precompiled, but on development it would be annoying to wrap all of them in one.
|
Beta Was this translation helpful? Give feedback.
-
Unfortunately my answer worked one time, but it stopped working for some reason, and I couldn't get it working again. To summarize the above, I'm having a couple of issues that I didn't have with Webpacker 5.x on my development environment:
I've dug through the change logs on Webpacker and compared the old and the new Webpack config for my project, but I could not find the issue. I'd appreciate any help. |
Beta Was this translation helpful? Give feedback.
-
I've recently upgraded from Webpacker 5.4.4 to Shakapacker 7.2.2, and I have defined some functions in my
app/javascript/packs/application.ts
to be used in JavaScript in my Rails views (app/views
). Here's an example:app/javascript/packs/application.ts
In my view, I use this function within a script tag, as follows:
On my development environment, when I load the page, I am getting
Uncaught ReferenceError: renderChSwiper is not defined
. However, I noticed that the function is defined when the page finishes loading by typing the name in the browser's developer tools console.Previously with Webpacker, this wasn't an issue: the function was defined. What could be different with Shakapacker that would cause this issue?
For reference, my
app/views/layouts/application.html.erb
file contains the Shakapacker assets:Beta Was this translation helpful? Give feedback.
All reactions