rails / sprockets

Rack-based asset packaging system
MIT License
956 stars 791 forks source link

manifest.js/link approach leads to empty manifest.js files in public/assets #639

Open jrochkind opened 5 years ago

jrochkind commented 5 years ago

Sprockets 4.0.0, Rails 5.2.3 or 6.0.0.

To use the new manifest.js/link approach, the manifest.js file in app/assets/config/manifest.js is added to the Rails config.assets.precompile.

The point of this is to make sprockets process it, so that any link(_*) commands in it are processed, determining other top-level targets.

However, it means that in Rails when you run ./bin/rake assets:precompile, you wind up with the manifest.js file itself compiled to public/assets as a top-level target. If it didn't have anything in it but link commands (as intended), it will be blank (except for maybe some newlines and/or comments).

But it will be there, at for instance public/assets/manifest-cadda289ef9c70eaa0879a36e6263cb33f7523a16b3ef862e0b8609cdc2bdab1.js.

While it doens't really hurt anything to have a blank file there, it is unneeded and a bit confusing, especially cause it can be easily confused with the entirely different sort of manifest file at eg .sprockets-manifest-6e2cb1cd0334645b62b0e7c72c401705.json. (The word "manifest" has been overloaded and used for several distinct things in sprockets land! The eg "application.css" file is also sometimes called a "manifest" file in sprockets and rails docs!)

I wonder if there's any way to rearchitect things to prevent this, although I can't think of one. It does seem at least worth pointing out, which perhaps the existince of this GH issue can help do.

josueadelima commented 3 years ago

Hi, when using Heroku buildpacks (Dokku) if the manifest-hash.json file exists, it used as the manifest file, even if .sprockets-hash.json exit's; it's weird because the build pack specify to use the .sprockets file first.