Problem with JS not working on Heroku
See original GitHub issueWhen including gem 'gentelella-rails'
. JS works fine on local but stops working on Heroku. i followed all the instructions. Using rails 5.1.2. Works fine if i remove gentelella-custom.js
file.
Issue Analytics
- State:
- Created 6 years ago
- Comments:12 (5 by maintainers)
Top Results From Across the Web
Troubleshooting Node.js Deploys - Heroku Dev Center
Your Node.js deploy failed - now what? Start with these simple steps to troubleshoot a build issue. Check the buildpack.
Read more >ruby on rails - Javascript not loading on heroku - Stack Overflow
My javascript is loading perfectly on development but it's not loading on the production. Even I am not getting any error in production....
Read more >javascript fails on Heroku, but fine locally
Again, it all works fine except on Heroku. Behavior suggests that the algo is failing in the regex area or in the random...
Read more >JavaScript fails on a fresh Rails App deployed to Heroku
I think there is a big problem with JavaScript files in Rails 5 apps in Production environment on Heroku. Steps to reproduce. Step...
Read more >Deploying a Back-End with Heroku - Codecademy
It's likely, at some point, that you run into an error when Heroku attempts to deploy your app. And even after successful deployments,...
Read more >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
turned out there were a total of three separate issues to resolve along the way.
1st: moment.js is required for fullcalendar. This has been added to the gem’s asset pipeline. Why it didn’t cause issues in development mode is a mystery!
2nd: It wasn’t enough to add just “gentelella.js” to the gem’s precompile list to fully build out the asset pipeline. This was prompting everyone to add *.js and *.css to their project’s precompile list.
3rd: datejs-rails is dormant, and has encoding issues that are unresolved since 2014, so I switched to bower to get latest sources.
To fix your project:
To get to the latest release of the gem. 0.1.8 at the time of this note.
REMOVE Rails.application.config.assets.precompile += %w( *.js *.css ) from your Rails project. If this line is left in, you’ll start see a whole new set of issues when it gets to bootstrap-sass gem. The long/short of it: adding that line to the gem pulled in exactly the right *.js and *.css that the gem depends on to work. Adding it to the Rails project pulls in every *.js and *.css of every gem in the Rails app and this gets messy quick!
Here’s a working Heroku deploy: https://stormy-shore-66376.herokuapp.com/index.html This is just the Rails 5.1.x example tweaked to use ‘pg’ gem. I will likely delete the Heroku dyno in a couple weeks, so check it out while you can.
@b-mandelbrot: That data/da-DK.js failing on invalid byte sequence seems to be a clue that there’s a problem encoding and compressing the JS with. However, I’m able to follow your steps and precompile everything on the demo rails project. Can you try to reproduce this with the demo?
@Talha5 node_modules could contain anything. Are you geting the same error writing da-DK-[fingerprint].js.gz? That is, the Encoding::InvalidByteSequenceError that @b-mandelbrot reports?