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

404 on assets/stimulus-loading.js with config.assets.digest set to false #108

Open
mrkcor opened this issue Sep 7, 2022 · 11 comments
Open

Comments

@mrkcor
Copy link

mrkcor commented Sep 7, 2022

When turning the asset digests off (https://guides.rubyonrails.org/asset_pipeline.html#turning-digests-off) in the development environment by setting config.assets.digest to false in config/environments/development.rb the file assets/stimulus-loading.js will not load and you will get an HTTP 404 for that file:

image

Changing config/importmap.rb to pin to stimulus-loading instead of stimulus-loading.js will make it work in the environments where the asset digests are turned off, the file will then however not be included in the production assets when precompiling them.

I have created a new Rails app where you can reproduce this issue here: https://github.com/mrkcor/stimulus-loading-issue

For anyone looking for a workaround for this issue: you can put a copy of the file stimulus-loading.js in vendor/javascript and pin the file as is indicated in the README.

@tripptuttle
Copy link

Hi @mrkcor, I just came to this repo to report the same bug. Thank you for the workarounds!

@mrkcor
Copy link
Author

mrkcor commented Sep 8, 2022

You're welcome @tripptuttle 😃

@rogerkk
Copy link

rogerkk commented Jan 31, 2023

Thanks @mrkcor, this helped me as well!

@mrkcor
Copy link
Author

mrkcor commented Feb 1, 2023

You're welcome @rogerkk 🙂

@awwaiid
Copy link

awwaiid commented Apr 1, 2023

Possibly related to rails/sprockets#749

@dhh
Copy link
Member

dhh commented Jun 18, 2023

Unable to reproduce on latest Rails and latest dependencies against a new stock app.

@dhh dhh closed this as completed Jun 18, 2023
@stefanoc
Copy link

@dhh this is easily reproducible with the latest stable Rails release (7.0.7):

% rails new assets-test && cd assets-test
% echo "Rails.application.config.assets.digest = false" >> config/initializers/assets.rb
% bin/rails s &
% curl http://localhost:3000/assets/stimulus-loading.js 

@dhh
Copy link
Member

dhh commented Aug 16, 2023

I had missed this was a specific issue with turning off assets digest. Why are folks doing that? Keeping those digests in development is the preferred approach. But I'll reopen anyway.

@dhh dhh reopened this Aug 16, 2023
@stefanoc
Copy link

stefanoc commented Aug 17, 2023

@dhh personally I never do it, but I was having some trouble with assets recompilation in development, and one of the suggested solutions was to set this in config/development.rb:

config.assets.compile = true
config.assets.digest = false

This is how I stumbled upon this issue.

@abumalick
Copy link

I was turning it off because of this issue with livereload: guard/guard-livereload#169 (comment)

@jontebol
Copy link

jontebol commented Oct 9, 2023

I had missed this was a specific issue with turning off assets digest. Why are folks doing that? Keeping those digests in development is the preferred approach. But I'll reopen anyway.

@dhh, I also got bitten by this when used together with guard/guard-livereload#169 (comment). Live reloading is wonderful together with Tailwind, makes designing directly in the browser so quick that I've stopped using Figma. However, setting up live reloading in Rails is usually a hassle. Have used chokidar with node earlier, and now using guard + rack-livereload. Neither option is as simple as it should be. Would be great to have a canonical and easy way to get it working on a new rails app without lot's of tricky dependencies.

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

No branches or pull requests

8 participants