Documentation
¶
Overview ¶
Package static reads and transforms static files.
Index ¶
Constants ¶
View Source
const ( BundleFile = "bundle.js" // generated file containing bundled JS IndexFile = "index.html" // file that initially loads JS )
Variables ¶
This section is empty.
Functions ¶
func GetFile ¶
GetFile returns the contents of the file at the specified path (without a leading slash) within staticDir.
Files are transformed in various ways:
- If GetFileMinify(true) is passed, the returned file is minified.
- If IndexFile is requested, scriptPlaceholder is replaced by BundleFile if minification is performed or by the JS version of bundleEntryPoint otherwise. remotePlayerPlaceholder is also replaced by "true" if GetFileRemotePlayer(true) is passed or by "false" otherwise, and buildTimestampPlaceholder is replaced by the string set via GetFileBuildTimestamp.
- If BundleFile is requested, bundleEntryPoint and all of its dependencies are returned as a single ES module. The code is minified regardless of whether minification was requested.
- If a nonexistent .js file is requested, its .ts counterpart is transpiled and returned.
Types ¶
type GetFileOption ¶
type GetFileOption func(*getFileConfig)
GetFileOption can be passed to GetFile to configure its behavior.
func GetFileBuildTimestamp ¶
func GetFileBuildTimestamp(ts string) GetFileOption
GetFileBuildTimestamp sets an opaque build timestamp to embed in the code.
func GetFileMinify ¶
func GetFileMinify(minify bool) GetFileOption
GetFileMinify specifies whether minification should be performed. By default, minification is not performed.
func GetFileRemotePlayer ¶
func GetFileRemotePlayer(remote bool) GetFileOption
GetFileRemotePlayer specifies whether the app should use the RemotePlayer class to communicate with a nup-headless instance (rather than LocalPlayer to play using <audio> elements). By default, RemotePlayer is not used.
Click to show internal directories.
Click to hide internal directories.