Sha256: 096a92eb3e91706569c5be0d66bb9fa20ced98da481c59d12582aca68798b6c6

Contents?: true

Size: 1.08 KB

Versions: 11

Compression:

Stored size: 1.08 KB

Contents

APPLICATION_LAYOUT_PATH = Rails.root.join("app/views/layouts/application.html.erb")

if APPLICATION_LAYOUT_PATH.exist?
  say "Add Importmap include tags in application layout"
  insert_into_file APPLICATION_LAYOUT_PATH.to_s, "\n    <%= javascript_importmap_tags %>", before: /\s*<\/head>/
else
  say "Default application.html.erb is missing!", :red
  say "        Add <%= javascript_importmap_tags %> within the <head> tag in your custom layout."
end

say "Create application.js module as entrypoint"
create_file Rails.root.join("app/javascript/application.js") do <<-JS
// Configure your import map in config/importmap.rb. Read more: https://github.com/rails/importmap-rails
JS
end

say "Ensure JavaScript files are in the asset pipeline manifest"
append_to_file Rails.root.join("app/assets/config/manifest.js"), %(//= link_tree ../../javascript .js\n)

say "Configure importmap paths in config/importmap.rb"
copy_file "#{__dir__}/config/importmap.rb", "config/importmap.rb"

say "Copying binstub"
copy_file "#{__dir__}/bin/importmap", "bin/importmap"
chmod "bin", 0755 & ~File.umask, verbose: false

Version data entries

11 entries across 11 versions & 1 rubygems

Version Path
importmap-rails-0.6.2 lib/install/install.rb
importmap-rails-0.6.1 lib/install/install.rb
importmap-rails-0.6.0 lib/install/install.rb
importmap-rails-0.5.3 lib/install/install.rb
importmap-rails-0.5.2 lib/install/install.rb
importmap-rails-0.5.1 lib/install/install.rb
importmap-rails-0.5.0 lib/install/install.rb
importmap-rails-0.4.3 lib/install/install.rb
importmap-rails-0.4.2 lib/install/install.rb
importmap-rails-0.4.1 lib/install/install.rb
importmap-rails-0.4.0 lib/install/install.rb