rails: ActionController::RoutingError (No route matches [GET] "/assets/application.js....)

I’m suddenly faced with

ActionController::RoutingError (No route matches [GET] "/assets/application.js-920efc795bbe74efc45b09c59b03e18109155fbdf62b008ca8d094aed269d334.map")

in a fresh rails 7 application using tailwind and esbuild. I cannot seem to locate where this is originating from. What might be causing this?

Removing

<%= javascript_include_tag "application", "data-turbo-track": "reload", defer: true %>

from the application.htlm.erb file removes the issue.

About this issue

  • Original URL
  • State: closed
  • Created 2 years ago
  • Comments: 17 (2 by maintainers)

Most upvoted comments

For me, I solved it by doing the following:

  1. Followed the advice of @fhcadmin above and removed everything from my assets build directory: rm -rf app/assets/builds/*

  2. Removed this line from config/environments/development.rb: config.assets.prefix = "/dev-assets"

Restarted by server with bin/dev and reloaded the page, the error was gone.

Hope that helps someone.

What worked for me?

rake assets:clobber

And then regenerate the source map.

Same issue here when migrating from webpacker to esbuild ActionController::RoutingError (No route matches [GET] "/assets/assets/application.css.map"): but weirdly for me it is adding wrong path when fetching the file. i’m not sure where it’s taking the path though here is my assets builds directory

and my manifest.js looks like this `//= link_tree …/images

//= link_tree …/builds`

looks like the /*# sourceMappingURL=assets/application.css.map */ sourceMappingURL is not proper so when browser parses the application.css file it looks at the comment and tries to load that file from and because of the invalid path it’s not able to find the .map file

https://esbuild.github.io/api/#sourcemap

Remove any css file import within your javascripts files and instead them in your application.scss (or whatever you call it)

For anybody googling this, manually clearing out the build artifacts fixes this

rm -rf app/assets/builds/*

@SkipKayhil