๐Ÿš€ Running Server in Development

๐Ÿง  Rails Server Shortcut

bundle exec rails s -p 3000

s is short for server and -p defines the port (e.g., 3000).


โšก Run Vite Separately

yarn dev --host

Run this in a separate terminal. Because "dev": "vite" is in package.json, this command starts the Vite server. --host makes it accessible over local network.


๐Ÿงฑ Using ESBuild for Production

In _bundle.html.erb, set condition to false, so that second block will execute:

<% if false %>
 ...
<% else %>
  <%= stylesheet_link_tag "#{entrypoint}", media: "all" %>
  <%= javascript_include_tag "#{entrypoint}", type: "module", crossorigin: "anonymous" %>
<% end %>

Then run:

yarn build

Restart Vite server after build.

Restore the condition to:

Rails.env.development? || Rails.env.test?


๐Ÿงช Summary