Sha256: 8cb62f3843197779581084555deeb305a97bbc6374a4ee5aa86f8b99a257d8a8
Contents?: true
Size: 1.25 KB
Versions: 2
Compression:
Stored size: 1.25 KB
Contents
APP_JS_ROOT = Rails.root.join("app/javascript") APP_JS_PATH = APP_JS_ROOT.join("application.js") IMPORTMAP_PATH = Rails.root.join("config/initializers/importmap.rb") if APP_JS_PATH.exist? say "Import Stimulus importmap autoloader in existing app/javascript/application.js" append_to_file APP_JS_PATH, %(\nimport "@hotwired/stimulus-importmap-autoloader"\n) else say <<~INSTRUCTIONS, :red You must import @hotwire/stimulus and @hotwire/stimulus-importmap-autoloader in your application.js. INSTRUCTIONS end say "Creating controllers directory" copy_file "#{__dir__}/app/javascript/controllers/hello_controller.js", APP_JS_ROOT.join("controllers/hello_controller.js") if IMPORTMAP_PATH.exist? say "Pin @hotwired/stimulus and @hotwired/stimulus-importmap-autoloader in config/initializers/importmap.rb" insert_into_file \ IMPORTMAP_PATH.to_s, %( pin "@hotwired/stimulus", to: "stimulus.js"\n pin "@hotwired/stimulus-importmap-autoloader", to: "stimulus-importmap-autoloader.js"\n pin_all_from "app/javascript/controllers", under: "controllers"\n\n), after: "Rails.application.config.importmap.draw do\n" else say <<~INSTRUCTIONS, :red You must add @rails/actiontext and trix to your importmap to reference them via ESM. INSTRUCTIONS end
Version data entries
2 entries across 2 versions & 1 rubygems
Version | Path |
---|---|
stimulus-rails-0.3.7 | lib/install/stimulus_with_asset_pipeline.rb |
stimulus-rails-0.3.6 | lib/install/stimulus_with_asset_pipeline.rb |