Skip to content

Setup with a generic rack application? #121

Answered by ElMassimo
burlesona asked this question in Q&A
Discussion options

You must be logged in to vote

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 render script and style tags.

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 resolve_entries will also return CSS files that should be injected as well, but it can be …

Replies: 1 comment

Comment options

You must be logged in to vote
0 replies
Answer selected by ElMassimo
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
2 participants