Static Assets
Globe offers built-in support for serving Static Files like images, HTML templates, and branding assets directly from your application. It works seamlessly with middleware's like shelf_static
Shelf and Dart Frog.
Specifying assets
You can specify directories or files using the syntax below in globe.yaml
config file similar to Flutter Asset Definition in your project directory.
Here is an example:
assets:
- assets/my_icon.png
- assets/background.png
To include all assets under a directory, specify the directory name with the / character at the end:
assets:
- directory/
- directory/subdirectory/
Globe will automatically detect common directories for frameworks such as
public/
, static/
, assets
. eg: For Serverpod, config/
,
migrations/
and web/
are automatically bundled.
Glob patterns
You can use glob-like *.png
to include matching files. For example, this configuration includes all .png files in the public/ directory:
assets:
- public/*.png
Mapping source and destination paths
You can use source_path:destination_path
to map files into Globe Runtime. This is useful for renaming or organising files when serving them:
assets:
- fake_lib_rust/target/fake_library.so:public/fake_library.so
Shelf + shelf_static
The code below demonstrates how to use Dart’s shelf and shelf_static middleware to serve a simple index.html
file:
Below is what our public/index.html
file looks like:
And now we deploy 🚀 using globe deploy
The image above shows the deployment process of a website built with Dart using Globe CLI. The terminal logs key steps, including queuing, in-progress status, and a final deployment URL.