Class

AssetHelper

asset-helper~AssetHelper

AssetHelper can be used to get paths and contents of various assets, including CSS and client JS. Do note that when reading files from disk, AssetHelper uses readFileSync, but then memoizes the result so that future requests are much faster.

You cannot use this class directly, but can access it's member functions as if they were static

import { assetPath } from "@quintype/framework/server/asset-helper";

Methods

assetFiles() → {Set.<string>}

Return a set of all assets

View Source server/impl/asset-helper-impl.js, line 167

A list of all assets

Set.<string>

assetHash(asset) → {string}

Get the fingerprint that the asset was assigned during compilation phase.

Parameters:
Name Type Description
asset string

The asset name

View Source server/impl/asset-helper-impl.js, line 155

The asset fingerprint

string

assetPath(asset, host) → {string}

Get tha path to an asset

Parameters:
Name Type Description
asset string

The asset name (ex: "app.js")

host string

The asset host (optional, this defaults to values from publisher.yml)

View Source server/impl/asset-helper-impl.js, line 59

Fully Qualified URL of the asset

string

getAllChunks(…chunks) → {Array.<module:asset-helper~Chunk>}

Read the given chunks into memory. This is a synonym for warmupAssetCache

Parameters:
Name Type Attributes Description
chunks string <repeatable>

The list of chunks

View Source server/impl/asset-helper-impl.js, line 124

getChunk(chunk) → {module:asset-helper~Chunk}

Loads a chunk into memory, usually so that it can be embedded onto the page

Parameters:
Name Type Description
chunk string

The name of the chunk to be fetched (ex: "list")

View Source server/impl/asset-helper-impl.js, line 100

The loaded chunk

getFilesForChunks(…chunks) → {Array.<string>}

Get a list of all JS and CSS files needed for a set of chunks

Parameters:
Name Type Attributes Description
chunks string <repeatable>

The list of chunks

View Source server/impl/asset-helper-impl.js, line 136

Unique list of JS and CSS files for a set of chunks

Array.<string>

readAsset(asset) → {string}

Return the contents of an asset as a string. This function will memoize the disk read, so that this function is much faster the next time.

Parameters:
Name Type Description
asset string

The asset name (ex: "app.js")

View Source server/impl/asset-helper-impl.js, line 72

The content of the asset

string

serviceWorkerContents() → {string}

Get the contents of the service worker.

View Source server/impl/asset-helper-impl.js, line 145

Service Worker Contents

string

warmupAssetCache(…chunks) → {void}

Read the given chunks into memory. This is a synonym for getAllChunks

Parameters:
Name Type Attributes Description
chunks string <repeatable>

The list of chunks

View Source server/impl/asset-helper-impl.js, line 91

void