Vite.View (vite_phx v0.3.2)
Help with View integration into Phoenix views
Link to this section Summary
Functions
Helper to generate HTML for a CSS link with static tracking
Helper to get HTML for all entry points at once
Generate all links for an entry struct in following order
Helper to generate inlined Phoenix cache manifest to simplify integration with Javascript code.
Helper to generate HTML for module preloading, eg
Helper to generate HTML for JS modules
The snippet for @vite/client
during development. Does nothing in :prod env.
The complete snippet for a single entry-point during prod. Delegates to vite dev-server otherwise. See :for_entry
for details.
Link to this section Functions
css_link(href, prefix)
Specs
Helper to generate HTML for a CSS link with static tracking:
<link phx-track-static rel="stylesheet" href="/some-styles.css"/>
for_entries(entries, prefix \\ "/")
Helper to get HTML for all entry points at once
for_entry(entry, prefix \\ "/")
Specs
Generate all links for an entry struct in following order:
- styles to prevent FOUC
- main entry script
- imports
<link phx-track-static rel="stylesheet" href="/assets/main.34asdfsf.css"/> <script type="module" crossorigin defer phx-track-static src="/assets/main.89abc777.js"></script> <link rel="modulepreload" href="/assets/_vendor.7788aaa.js">
inlined_phx_manifest()
Specs
Helper to generate inlined Phoenix cache manifest to simplify integration with Javascript code.
The manifest generated by mix phx.digest
is stored in a global variable window.PhxManifest
.
Only works in :prod environment.
module_preload(href, prefix)
Specs
Helper to generate HTML for module preloading, eg:
<link rel="modulepreload" href="/a-module.js">
module_script(src, prefix)
Specs
Helper to generate HTML for JS modules
Has automatic inclusion of defer
, crossorigin
and phx-track-static
attributes.
<script type="module" crossorigin defer phx-track-static src="/module.js"></script>
vite_client()
Specs
The snippet for @vite/client
during development. Does nothing in :prod env.
vite_snippet(entry_name)
Specs
The complete snippet for a single entry-point during prod. Delegates to vite dev-server otherwise. See :for_entry
for details.