Skip to content

Instantly share code, notes, and snippets.

@MyklClason
Last active July 21, 2019 22:03
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save MyklClason/09c6f58b9e6d21340582cbd6fbd3b8b8 to your computer and use it in GitHub Desktop.
Save MyklClason/09c6f58b9e6d21340582cbd6fbd3b8b8 to your computer and use it in GitHub Desktop.
Rails StimulusJS setup

Yarn

https://yarnpkg.com/lang/en/docs/install/#debian-stable

Run Commands

curl -sS https://dl.yarnpkg.com/debian/pubkey.gpg | sudo apt-key add -
echo "deb https://dl.yarnpkg.com/debian/ stable main" | sudo tee /etc/apt/sources.list.d/yarn.list
sudo apt-get update && sudo apt-get install --no-install-recommends yarn

Webpacker (if needed)

https://github.com/rails/webpacker (Check for latest directions)

Add gem

gem 'webpacker', '~> 4.x'

Run Commands

bundle install
bundle exec rails webpacker:install

StimulusJS

Run Commands

bundle exec rails webpacker:install:stimulus

Views

Be sure to add the webpack helpers where needed.

<%= javascript_pack_tag 'application' %>

Config

To allow for ES6 usage.

config.assets.js_compressor = Uglifier.new(harmony: true)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment