Rails 7, webpack and jsbundling production compilation

Hi everyone,

I upgraded to rails 7 from rails 6.x and decided to keep my webpack configuration. Ι followed the migration guide here https://github.com/rails/jsbundling-rails/blob/main/docs/switch_from_webpacker.md and everything worked fine.

My problem is when I run : RAILS_ENV=production rails assets:precompile. The error i get is

SassC::SyntaxError: Error: Invalid CSS after “…nd_css.js.map*/”: expected “}”, was “” on line 48:42 of stdin

/# sourceMappingURL=backend_css.js.map/

I get no errors if I do:

RAILS_ENV=development rails assets:precompile

Why is this happening in production mode? 

Thank  you

If you’re going to stick with either webpack or esbuild, consider webpacker v6, aka Shakapacker, https://github.com/shakacode/shakapacker.

If you stick with jsbundling-rails, you’ll have some extra code to maintain.

The current jsbundling-rails requires some special handling for different envs:

Note, I have no idea if this step works.

We’re testing the basic configurations with Shakapacker v6. If you get this error there, we’ll fix the issue.

Otherwise, please report the issue and better yet, put in a PR for the docs.



just using shakapacker

jsbundling or cssbundling There are too many limitations, the function is not strong

And the static files they produce, there will be many problems with Assets Pipeline.

Why not use the successor to webpacker: