Assets Class

Defined in: lib/Assets.js

A registry for all static assets that need to be present at run-time, like stylesheets, JavaScript scripts, image files, or whatever.

Assets can be accessed by their original path prefixed by /assets/. For example, for an image found at doc/images/lol.jpg, it can be referenced in the sources at /assets/doc/images/lol.jpg.

Public Functions

voidadd(String, String)
voidaddStyleSheet()
voidaddRuntimeScript(String)

Constructor Documentation

Assets()

Instance Method Documentation

    add(path: String, outputPath: String)

    Add a static file (or directory) to the asset listing.

    Parameters (2)

    path
    String

    The path of the asset relative to the Config@assetRoot. This can either be a path to a single file, or a directory of files.

    outputPath
    String

    If present, you may specify an absolute path to where the asset should be copied (this will still be relative to the output directory, however.)

    When this is not present, we assume the output path to be the source path prefixed by "/assets/".

    addRuntimeScript(path: String)

    Add a script that will be included by the resulting HTML file.

    Parameters (1)

    path
    String

    The path relative to the HTML file to where the script will be located. Note that you are responsible to stage and copy the file yourself using something like AssetUtils#writeAsset.

    addStyleSheet()

    Add a stylesheet of type .css or .less to the asset listing. This stylesheet will be processed during compilation through the LESS processor.