@@ -313,7 +313,7 @@ def jbuilder_gemfile_entry
313
313
def javascript_gemfile_entry
314
314
return [ ] if options [ :skip_javascript ]
315
315
316
- if options [ :javascript ] == "importmap"
316
+ if adjusted_javascript_option == "importmap"
317
317
GemfileEntry . version ( "importmap-rails" , ">= 0.3.4" , "Use JavaScript with ESM import maps [https://github.com/rails/importmap-rails]" )
318
318
else
319
319
GemfileEntry . version "jsbundling-rails" , "~> 0.1.0" , "Bundle and transpile JavaScript [https://github.com/rails/jsbundling-rails]"
@@ -336,6 +336,16 @@ def using_node?
336
336
options [ :javascript ] && options [ :javascript ] != "importmap"
337
337
end
338
338
339
+ # CSS processors other than Tailwind require a node-based JavaScript environment. So overwrite the normal JS default
340
+ # if one such processor has been specified.
341
+ def adjusted_javascript_option
342
+ if options [ :css ] && options [ :css ] != "tailwind" && options [ :javascript ] == "importmap"
343
+ "esbuild"
344
+ else
345
+ options [ :javascript ]
346
+ end
347
+ end
348
+
339
349
def css_gemfile_entry
340
350
return [ ] unless options [ :css ]
341
351
@@ -407,9 +417,9 @@ def run_bundle
407
417
def run_javascript
408
418
return if options [ :skip_javascript ] || !bundle_install?
409
419
410
- case options [ :javascript ]
420
+ case adjusted_javascript_option
411
421
when "importmap" then rails_command "importmap:install"
412
- when "webpack" , "esbuild" , "rollup" then rails_command "javascript:install:#{ options [ :javascript ] } "
422
+ when "webpack" , "esbuild" , "rollup" then rails_command "javascript:install:#{ adjusted_javascript_option } "
413
423
end
414
424
end
415
425
0 commit comments