Asset ViewHelper <vite:asset>

The vite:asset ViewHelper embeds all JavaScript and CSS belonging to the specified vite entry using TYPO3's AssetCollector API.

Example

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

<vite:asset
    entry="EXT:sitepackage/Resources/Private/JavaScript/Main.entry.js"
/>
Copied!

Advanced Example

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

<vite:asset
    manifest="EXT:sitepackage/Resources/Public/Vite/.vite/manifest.json"
    entry="EXT:sitepackage/Resources/Private/JavaScript/Main.entry.js"
    scriptTagAttributes="{
        type: 'text/javascript',
        async: 1
    }"
    cssTagAttributes="{
        media: 'print'
    }"
    priority="1"
/>
Copied!

Arguments

The following arguments are available for the asset ViewHelper:

addCss

addCss
Type
boolean
Default
true
If set to "false", CSS files associated with the entry point won't be added to the asset collector

cssTagAttributes

cssTagAttributes
Type
array
Default
array ( )
Additional attributes for css link tags.

devTagAttributes

devTagAttributes
Type
array
Default
array ( )
HTML attributes that should be added to script tags that point to the vite dev server

entry

entry
Type
string
Identifier of the desired vite entrypoint; this is the value specified as "input" in the vite configuration file. Can be omitted if manifest file exists and only one entrypoint is present.

manifest

manifest
Type
string
Path to your manifest.json file. If omitted, default manifest from extension configuration will be used instead.

priority

priority
Type
boolean
Default
false
Include assets before other assets in HTML

scriptTagAttributes

scriptTagAttributes
Type
array
Default
array ( )
HTML attributes that should be added to script tags for built JavaScript assets

useNonce

useNonce
Type
bool
Default
false
Whether to use the global nonce value