Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Heroku not building js, rare behavior #82

Closed
michelson opened this issue Feb 7, 2022 · 5 comments
Closed

Heroku not building js, rare behavior #82

michelson opened this issue Feb 7, 2022 · 5 comments

Comments

@michelson
Copy link

Hello there, I've been days banging my head on this, and I could not explain what's happening:

I'm using jsbundling on a Rails 6.1.4.4 / sprockets (4.0.2), the compilation works on local, ( files are stored in app/assets/build and served properly by sprockets). I can see the app running ok, but when I deploy to Heroku the rails assets:precompile I get different results.,

In Heroku, the asset files are not copied to the public/assets. It seems that it find files on public/assets, so it skips that part.
I've done an "enhance" to the assets:precompile rake task in order to remove all the files in the public/assets before the precompilation. That way, it generates the files in Heroku, but the JS files are not copied into public/assets 🤯. It copies only a portion of the assets, like images and CSS but not the .js file. I've replicated that in a github action build where the config.assets is config.assets.compile = false so it kinda replicates what's happening in production.

I've tried many strategies to get this working but without avail. Has anyone seen this rare behavior before?

@michelson
Copy link
Author

michelson commented Feb 7, 2022

also running the RAILS_ENV=test rails assets:precompile in local gives me different results as Heroku or my CI (it does not matter if config.assets is true or false), in local it does compile and copies the JS to public/assets properly, so, I'm clueless :(

@marckohlbrugge
Copy link

Did you solve this? I'm running into the same problem on Render

@marckohlbrugge
Copy link

I solved it by making sure there was an app/assets/builds directory. Also see #60

@michelson
Copy link
Author

michelson commented Feb 10, 2022

oh, it works!

It works, but my images src are broken, I see that the image files were copied to public/assets but the js is linking to the unhashed version.

so in I have both files, one at app/assets/builds/img-123.jpg the other is copied to public/assets/image-123-[HASH].jpg, but the js script is still calling src="/assets/img-123.jpg"

it seems this is related to the #15

@michelson
Copy link
Author

I will close this as the specific issue was solved.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants