stimulus-rails 0.3.9 → 1.0.2
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/README.md +20 -31
- data/app/assets/javascripts/stimulus-autoloader.js +2 -0
- data/app/assets/javascripts/stimulus-importmap-autoloader.js +18 -12
- data/app/assets/javascripts/stimulus-loading.js +81 -0
- data/app/assets/javascripts/stimulus.js +1948 -1
- data/app/assets/javascripts/stimulus.min.js +5 -0
- data/app/assets/javascripts/stimulus.min.js.map +1 -0
- data/lib/generators/stimulus/USAGE +15 -0
- data/lib/generators/stimulus/stimulus_generator.rb +20 -0
- data/lib/generators/stimulus/templates/controller.js.tt +7 -0
- data/lib/install/app/javascript/controllers/application.js +9 -0
- data/lib/install/app/javascript/controllers/index_for_importmap.js +11 -0
- data/lib/install/app/javascript/controllers/index_for_node.js +8 -0
- data/lib/install/stimulus_with_importmap.rb +19 -0
- data/lib/install/stimulus_with_node.rb +18 -0
- data/lib/stimulus/engine.rb +1 -1
- data/lib/stimulus/manifest.rb +28 -0
- data/lib/stimulus/version.rb +1 -1
- data/lib/tasks/stimulus_tasks.rake +33 -11
- metadata +16 -8
- data/app/assets/javascripts/stimulus@2.js +0 -1699
- data/lib/install/app/javascript/controllers/index.js +0 -9
- data/lib/install/stimulus_with_asset_pipeline.rb +0 -27
- data/lib/install/stimulus_with_webpacker.rb +0 -11
@@ -1,9 +0,0 @@
|
|
1
|
-
// Load all the controllers within this directory and all subdirectories.
|
2
|
-
// Controller files must be named *_controller.js or *_controller.ts.
|
3
|
-
|
4
|
-
import { Application } from "stimulus"
|
5
|
-
import { definitionsFromContext } from "stimulus/webpack-helpers"
|
6
|
-
|
7
|
-
window.Stimulus = Application.start()
|
8
|
-
const context = require.context("controllers", true, /_controller\.(js|ts)$/)
|
9
|
-
Stimulus.load(definitionsFromContext(context))
|
@@ -1,27 +0,0 @@
|
|
1
|
-
APP_JS_ROOT = Rails.root.join("app/javascript")
|
2
|
-
APP_JS_PATH = APP_JS_ROOT.join("application.js")
|
3
|
-
IMPORTMAP_PATH = Rails.root.join("config/importmap.rb")
|
4
|
-
|
5
|
-
if APP_JS_PATH.exist?
|
6
|
-
say "Import Stimulus importmap autoloader in existing app/javascript/application.js"
|
7
|
-
append_to_file APP_JS_PATH, %(\nimport "@hotwired/stimulus-importmap-autoloader"\n)
|
8
|
-
else
|
9
|
-
say <<~INSTRUCTIONS, :red
|
10
|
-
You must import @hotwired/stimulus and @hotwired/stimulus-importmap-autoloader in your application.js.
|
11
|
-
INSTRUCTIONS
|
12
|
-
end
|
13
|
-
|
14
|
-
say "Creating controllers directory"
|
15
|
-
copy_file "#{__dir__}/app/javascript/controllers/hello_controller.js", APP_JS_ROOT.join("controllers/hello_controller.js")
|
16
|
-
|
17
|
-
if IMPORTMAP_PATH.exist?
|
18
|
-
say "Pin @hotwired/stimulus and @hotwired/stimulus-importmap-autoloader in config/importmap.rb"
|
19
|
-
insert_into_file \
|
20
|
-
IMPORTMAP_PATH.to_s,
|
21
|
-
%( 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),
|
22
|
-
after: "Rails.application.config.importmap.draw do\n"
|
23
|
-
else
|
24
|
-
say <<~INSTRUCTIONS, :red
|
25
|
-
You must add @hotwired/stimulus and @hotwired/stimulus-importmap-autoloader to your importmap to reference them via ESM.
|
26
|
-
INSTRUCTIONS
|
27
|
-
end
|
@@ -1,11 +0,0 @@
|
|
1
|
-
say "Appending Stimulus setup code to #{Webpacker.config.source_entry_path}/application.js"
|
2
|
-
append_to_file "#{Webpacker.config.source_entry_path}/application.js", %(\nimport "controllers")
|
3
|
-
|
4
|
-
say "Creating controllers directory"
|
5
|
-
directory "#{__dir__}/app/javascript/controllers", "#{Webpacker.config.source_path}/controllers"
|
6
|
-
|
7
|
-
say "Using Stimulus NPM package"
|
8
|
-
gsub_file "#{Webpacker.config.source_path}/controllers/hello_controller.js", /@hotwired\//, ''
|
9
|
-
|
10
|
-
say "Installing all Stimulus dependencies"
|
11
|
-
run "yarn add stimulus"
|