Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Don't delete the javascript that rails 7 generates #2834

Merged
merged 1 commit into from
Oct 11, 2022
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 9 additions & 3 deletions lib/generators/blacklight/assets_generator.rb
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,6 @@ def appease_rails7
return unless Rails.version > '7'

gem "sassc-rails", "~> 2.1"

remove_file 'app/javascript/application.js'
end

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

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

private

def root
@root ||= Pathname(destination_root)
end

def using_importmap?
@using_importmap ||= root.join('config/importmap.rb').exist?
end

def turbolinks?
@turbolinks ||= application_js.include?('turbolinks')
end
Expand Down