Skip to content

Commit dd20e84

Browse files
committed
Rails New: Only add browser restrictions when using importmap
This commit changes the generator for new Rails applications to only add: ```ruby allow_browser versions: :modern ``` If the application is generated with `--javascript=importmap`. This is the default, so this PR does not change anything for people that do not override the JavaScript option.
1 parent 36601bb commit dd20e84

File tree

2 files changed

+5
-3
lines changed

2 files changed

+5
-3
lines changed

railties/CHANGELOG.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -104,4 +104,8 @@
104104

105105
*Petrik de Heus*
106106

107+
* Only add browser restrictions for a new Rails app when using importmap.
108+
109+
*Lucas Dohmen*
110+
107111
Please check [8-0-stable](https://github.com/rails/rails/blob/8-0-stable/railties/CHANGELOG.md) for previous changes.
Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,9 @@
11
class ApplicationController < ActionController::<%= options.api? ? "API" : "Base" %>
2-
<%- unless options.api? -%>
2+
<%- if using_importmap? -%>
33
# Only allow modern browsers supporting webp images, web push, badges, import maps, CSS nesting, and CSS :has.
44
allow_browser versions: :modern
5-
<%- if using_importmap? -%>
65

76
# Changes to the importmap will invalidate the etag for HTML responses
87
stale_when_importmap_changes
98
<% end -%>
10-
<% end -%>
119
end

0 commit comments

Comments
 (0)