View Engine

The view engine provides a comprehensive set of methods to render and build React template views for both server and client. You can get the view engine like the following.
Copy

builder

Returns the view builder
Copy

config

The final computed configuation for the view engine.
Copy

paths

The final computed configuation for the view engine.
Copy
Copy
Copy
Copy
Copy

production

Returns true if mode is production
Copy

routes

Returns the route prefixes
Copy
Copy

size

Returns the size of the manifest
Copy

templates

Returns the templates
Copy
Copy
Copy

viteConfig

Returns the computed vite configuration
Copy

build()

Tries to return the vite build callback
Copy

dev()

Tries to return the raw vite dev server
Copy

http()

Returns the HTTP middleware needed to serve the assets in dev mode.

Usage

Copy

Example

Copy

middlewares()

Returns the raw Vite middlewares used to serve the assets in dev mode.
Copy

plugins()

Returns the raw Vite plugins.
Copy

fetch()

Imports a URL using the dev server.
Copy

import()

Imports the page component to runtime for dev mode
Copy

resolve()

Returns the absolute filepath to the entry file. Throws an Exception if the file is not found.
Copy

buildAllAssets()

Builds and saves the assets used from all the documents.
Copy

buildAllClients()

Builds and saves the client entries from all the documents
Copy

buildAllPages()

Builds and saves the pages scripts from all the documents
Copy

entries()

Returns a list of manifest entries
Copy

find()

Returns a Document by ID
Copy

forEach()

Calls a function for each key/value pair in the manifest. The function is called with the value, key and the map itself as arguments.
Copy

get()

Returns the Document associated with the entry file. If the entry file does not exist in the manifest, it will return undefined.
Copy

has()

Returns true if the entry file exists in the manifest, otherwise it will return false.
Copy

load()

Sets the manifest from given object
Copy

open()

Loads the manifest from disk
Copy

map()

Loop through the manifest and re-assigns the values
Copy

save()

Saves the manifest to disk.
Copy

set()

Sets an entry in the manifest and returns a document
Copy

toJSON()

Converts the manifest to hash
Copy

absolute()

Returns the absolute path to the entry file
Copy

id()

Generates an id for the entry file
Copy

importPage()

Imports the page component to runtime
Copy

relative()

Returns the absolute path to the entry file
Copy

buildAssets()

Returns the final client entry source code (js) and assets
Copy

buildClient()

Returns the final client entry assets
Copy

buildPage()

Returns the final page component source code (js)
Copy

renderHMR()

Returns the client entry for HMR (js)

Usage

Copy

example

Copy

render()

Returns the final document markup (html)

Usage

Copy

example

Copy