0

Given the following setup:

  • Rails Gem with mountable Engine containing some common functionality using Ruby- and Javascript-Code. Javascript is mainly used in Stimulus-Controllers
  • Rails 8 Application mounting the Engine-Gem. JS-Building using Vite (vite_rails).

For the vitejs/engine-integration i followed ElMassimos's example https://github.com/ElMassimo/vite_ruby/blob/main/examples/rails/example_engine/README.md

When running in development-mode, everything seems to work nice. Changing to production-mode with using deploy:assets:precompile in the application mounting the engine i am getting the following error:

error during build:
[vite]: Rollup failed to resolve import "@hotwired/stimulus" from "[...]/ruby/3.4.0/bundler/gems/dynamic_profile_form_engine-201bd9660c12/app/javascript/controllers/edit_profile_controller.js".

In the engine we are using @hotwired/stimulus, which is defined in its package.json. It is possible to successfully run bin/vite build in the engine too, but how to let the mounting application include this?

What is missing to knit it all together for deployment?

0

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.