Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Save vmcilwain/dafc73b7df2ed1d38a366e8e613536db to your computer and use it in GitHub Desktop.
Save vmcilwain/dafc73b7df2ed1d38a366e8e613536db to your computer and use it in GitHub Desktop.
How I migrated from import maps to esbuild and bootstrap after implementing action text

Found the following instructions that got me to the point where esbuild replaced import maps and bootstrap was installed.

https://mixandgo.com/learn/ruby-on-rails/how-to-install-bootstrap

You will find that even after fixing the Javascript issues Javascript still does not work. When looking in the log files I saw there were issues with trix loading as well as issues with importing stimulus controllers.

What I ended up doing was modifying package.json and add the following:

"@rails/actiontext": "^7.0.4",
"trix": "^2.0.4"

I then modified app/assets/stylesheets/application.bootstrap.scss and added the following line:

@import 'actiontext.css';

Finally, I ran ./bin/rails stimulus:manifest:update in terminal to update app/javascript/controllers/index.js to register all of the stimulus controllers I had created.

You should then be able to run bin/dev and (hopefully) shouldn't see any errors.

I was able to quickly install a boostrap nav bar and make sure that the dropdown worked indicating the Javascript was functioning.

I then checked any place I implemented action text functioned ok as well as any places where I implemented a stimulus controller to make sure those were working.

If in the event, you still have errors popping up, the way I figured things out was to generate a new rails app with action text to see how the code was generated:

rails new trixtest -j esbuild --css bootstrap
bin/rails action_text:install

I would start by comparing the following between the new app and your existing app

  • package.json
  • app/javascript/application.js
  • app/assets/config/manifest.js
  • app/javascript/controllers/index.js
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment