Skip to content

Commit 0594d76

Browse files
committed
Don't delete the javascript that rails 7 generates
1 parent 656af36 commit 0594d76

File tree

1 file changed

+9
-3
lines changed

1 file changed

+9
-3
lines changed

lib/generators/blacklight/assets_generator.rb

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -15,8 +15,6 @@ def appease_rails7
1515
return unless Rails.version > '7'
1616

1717
gem "sassc-rails", "~> 2.1"
18-
19-
remove_file 'app/javascript/application.js'
2018
end
2119

2220
# Add sprockets javascript if needed
@@ -37,7 +35,7 @@ def create_sprockets_javascript
3735
# Remove the empty generated app/assets/images directory. Without doing this,
3836
# the default Sprockets 4 manifest will raise an exception.
3937
def appease_sprockets4
40-
return if !defined?(Sprockets::VERSION) || Sprockets::VERSION < '4'
38+
return if !defined?(Sprockets::VERSION) || Sprockets::VERSION < '4' || using_importmap?
4139

4240
append_to_file 'app/assets/config/manifest.js', "\n//= link application.js"
4341
empty_directory 'app/assets/images'
@@ -74,6 +72,14 @@ def assets
7472

7573
private
7674

75+
def root
76+
@root ||= Pathname(destination_root)
77+
end
78+
79+
def using_importmap?
80+
@using_importmap ||= root.join('config/importmap.rb').exist?
81+
end
82+
7783
def turbolinks?
7884
@turbolinks ||= application_js.include?('turbolinks')
7985
end

0 commit comments

Comments
 (0)