Sha256: e8b1f2fdaf021677ded8d2f6dcc51703ea832bf586ade605d00f1e3d9e3b3ee7
Contents?: true
Size: 1.19 KB
Versions: 1
Compression:
Stored size: 1.19 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/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 @hotwired/stimulus and @hotwired/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/importmap.rb" append_to_file \ IMPORTMAP_PATH.to_s, %(pin "@hotwired/stimulus", to: "stimulus.js"\npin "@hotwired/stimulus-importmap-autoloader", to: "stimulus-importmap-autoloader.js"\npin_all_from "app/javascript/controllers", under: "controllers"\n) else say <<~INSTRUCTIONS, :red You must add @hotwired/stimulus and @hotwired/stimulus-importmap-autoloader to your importmap to reference them via ESM. INSTRUCTIONS end
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
stimulus-rails-0.3.11 | lib/install/stimulus_with_asset_pipeline.rb |