Resource.vite ViewHelper <vite:resource.vite>

The resource.vite ViewHelper extracts the uri to one specific asset file from a vite manifest file. If the dev server is used, the dev server uri to the resource is returned.

Example

This can be used to preload certain assets in the HTML <head> tag:

<html
    data-namespace-typo3-fluid="true"
    xmlns:vac="http://typo3.org/ns/Praetorius/ViteAssetCollector/ViewHelpers"
>

<f:section name="HeaderAssets">
    <link
        rel="preload"
        href="{vac:resource.vite(file: 'EXT:sitepackage/Resources/Private/Fonts/webfont.woff2')}"
        as="font"
        type="font/woff2"
        crossorigin
    />
</f:section>
Copied!

Arguments

The following arguments are available for the resource.vite ViewHelper:

file
Type
string
Required
1
Identifier of the desired asset file for which a uri should be generated
manifest
Type
string
Path to vite manifest file; if omitted, default manifest from extension configuration will be used instead