-
I'm specifically interested in using Vite Ruby with Roda. I followed the guide, but there's very little content for using What is not clear is how this should be integrated into a generic rack app. I'm trying to read the source code and connect the dots, but I'm not quite there. Presumably I need to use the ViteRuby's asset methods to link to I see how in the framework plugins there are template helpers that do this, and I understand why in a plain Rack app there's no way to automatically provide such helpers, but I was expecting to find something like Also it seems like the browser will not like doing that with a different host in development, but I see in the source that there's a proxy dev server which I assume is meant to be used as middleware to proxy requests from localhost: to localhost: so that the browser doesn't know there are two things running. So, step 1 for a Rack app is I think I'm close here, but would love a little help if anyone can fill in some of these blanks for me. Thank you! |
Beta Was this translation helpful? Give feedback.
Replies: 1 comment
-
Hi Andrew! By default, running Once the proxy is in place, the next step is to use For example, for stylesheets the most basic implementation would be: <link rel="stylesheet" href="<%= vite_manifest.path_for('styles', type: :stylesheet) %>" media="all"/> You would typically encapsulate this as: <%= vite_stylesheet_tag 'styles' %> For javascript it's a bit more complex, as I initially intended to create If you find some primitives in Roda that would allow to implement this concisely, let me know and I'll reconsider it. |
Beta Was this translation helpful? Give feedback.
Hi Andrew!
By default, running
bundle exec vite install
in a plain Rack app will attempt to configure the dev server proxy.Once the proxy is in place, the next step is to use
ViteRuby.instance.manifest
and use its public methods to obtain the URLs corresponding to the resources, and renderscript
andstyle
tags.For example, for stylesheets the most basic implementation would be:
You would typically encapsulate this as:
For javascript it's a bit more complex, as
resolve_entries
will also return CSS files that should be injected as well, but it can be …