BundledWebResources.LocalResource
— TypeLocalResource(root::AbstractString, path::AbstractString, [transform::Function])
Define a local resource to be served at the given path
. Optionally specify a transform
function that takes outputs the contents of path
as a String
instead; used for resources that need pre-processing, e.g. TypeScript.
BundledWebResources.Resource
— TypeResource(url::String; name::String, sha256::String)
A remote resource that is downloaded and cached locally.
BundledWebResources.ResourceRouter
— MethodResourceRouter(mod::Module)
A middleware that serves resources defined in mod
at the paths returned by pathof
for each resource.
BundledWebResources.bun_build
— Functionbun_build([source])
On-the-fly building of local scripts using bun
as the build tool.
If the source file and the build artifact are different file types, e.g. TypeScript, not JavaScript, then specify source
as the .ts
file.
BundledWebResources.watch
— Methodwatch(;
root::AbstractString = pwd(),
entrypoint::AbstractString = "input.ts",
outdir::AbstractString = "dist",
after_rebuild::Function,
) -> Watcher
Runs bun build --watch
in the given root
directory, watching the entrypoint
file and writing to the outdir
directory. after_rebuild
is called whenever the build finishes. This is a zero-argument function that can be used to run any code after the rebuild finishes, such as browser auto-reloaders.
The returned Watcher
object can be close
d to stop the watcher.
BundledWebResources.@comptime
— Macro@comptime ex
Evaluate an expression at compile time. This is useful for constructing Resource
objects at compile time, e.g.:
my_resource() = @comptime Resource("https://example.com/my_resource.txt"; sha256="...")
while still allowing the value to be "Revise
-able", since it isn't a global constant, and instead is a function return value.