Using the build command I get a sourcemap in app/assets/builds
Specifically, I get a file application.js.map
But in my browser, Firefox, it always complains as it is looking for the long bundled awkward name for things, and it never finds that. So I get an error all the time in my console looking something like this:
Source Map URL: application.js-e84a27730b114085524199296fb80196530bd624085878c84ebd17a1a0eeead3.map
Is there a way to clean this up? It seems like there is a missing step somewhere, and I am not smart enough to figure it out. I can delete the --sourcemap directive and remove the application.js.map from my builds completely, and I care not… but I am sure for debugging purposes, that might be a dumb idea.
Are you referring to this map file by using any helper methods in your layouts?
Did you remove the
config.assets.debug = true line from the
Nope. That line exists.
config.assets.debug = true
Interesting point! App has no view helpers. The one gem I use that does affect views, I checked, and nothing jumps out as rendering anything to do with the build assets.
After recently switching to jsbundling-rails I could not get sourceMaps to work and filed this issue (not sure if it is the same issue you are facing):
At first glance it looked related to Sprockets, so I thought I could try Propshaft instead, but our app has a dependency currently incompatible with it (and anyway Propshaft is still alpha).
At least I know I am not the only one! This sat for weeks on StackOverflow with no one understanding my question, but now it is nicely narrowed down to using Sprockets and ESBuild.
You need to remove that line(option) in order to get the maps working. Probably you have upgraded rails 6 app to esbuild. If that line stays Rails will look for the maps in the wrong place(“old” sprockets source maps). This is why new rails 7 app does’t have that line
So in development configs, remove that line about config.assets.debug = true. OK. Thanks for the hot tip. I will try that and report back.
Our Rails 7 app does not have
config.assets.debug defined, and yet the source maps directive at the end of the JS bundle file does not survive after going through sprockets (even though it is present in the esbuild generated file). (See issue for details.)