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

Support Stimulus Default Pack #1255

Merged
merged 2 commits into from
Feb 8, 2018
Merged

Support Stimulus Default Pack #1255

merged 2 commits into from
Feb 8, 2018

Conversation

ytbryan
Copy link
Contributor

@ytbryan ytbryan commented Feb 8, 2018

This PR is adding support of Stimulus via Webpacker.

  • Install Stimulus dependencies
  • Add a app/javascript/packs/controllers directory
  • Append the setup code to app/javascript/packs/application.js
  • Add a simple "Hello Stimulus" example.
  • Edit readme

For more information on Stimulus, please go to stimulusjs.org or read The Stimulus Handbook


To try it now:

#At Gemfile
gem 'webpacker', github: 'ytbryan/webpacker'
bundle install 
rails webpacker:install
rails webpacker:install:stimulus
rails g scaffold pages
rails db:migrate

Paste this into your pages#index

<div data-controller="hello>
   <h1 data-target="hello.output"></h1>
</div>
<%= javascript_pack_tag 'application' %> 
rails server

And visit http://localhost:3000/pages

webpacker:install:stimulus

added controllers directory and hello_controller.js

HELLO stimulus!

Wrapping it up with stimulus.rb

include stimulus in README.md

Remove hello_stimulus.js

Append setup code to application.js

👮‍♂️Satisfy robocop

From CI "Use the new Ruby 1.9 hash syntax.
inject_into_file "#{Webpacker.config.source_entry_path}/application.js", :after => "console.log('Hello World from Webpacker')" do"

use append_to_file instead of inject_into_file
add whitespace

rename setup.js to application.js
remove whitespace

added a \n
this.outputTarget.textContent = 'Hello Stimulus!'

✂️

✂️ to appease robocop

fix: cannot find module "controllers"

revert back to "controllers"

Added the expectant HTML in comments. 🤰

✂️, Edit comments, and changed to 'Hello, Stimulus!'

Use source_path instead of source_entry_path

missing "
@ytbryan ytbryan mentioned this pull request Feb 8, 2018
@javan javan merged commit 89e4d60 into rails:master Feb 8, 2018
@javan
Copy link
Contributor

javan commented Feb 8, 2018

Thank you!

@ytbryan
Copy link
Contributor Author

ytbryan commented Feb 8, 2018

Thanks for your patience!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants