Skip to content
8 changes: 8 additions & 0 deletions docs/hub/spaces-config-reference.md
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,14 @@ Value must be one of `"small"`, `"medium"` or `"large"`.
Path to your main application file (which contains either `gradio` or `streamlit` Python code, or `static` html code).
Path is relative to the root of the repository.

**`app_build_command`** : _string_
For static Spaces, command to run first to generate the HTML to render. Example: `npm run build`.

This is used in conjunction with `app_file` which points to the built index file: e.g. `app_file: dist/index.html`.

Each update, the build command will run in a Job and the build output will be stored in `refs/convert/build`,
which will be served by the Space. See an example at https://huggingface.co/spaces/coyotte508/static-vite

**`app_port`** : _int_
Port on which your application is running. Used only if `sdk` is `docker`. Default port is `7860`.

Expand Down
19 changes: 19 additions & 0 deletions docs/hub/spaces-sdks-static.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,25 @@ Here are some examples of Spaces using custom HTML:

* [Smarter NPC](https://huggingface.co/spaces/mishig/smarter_npc): Display a PlayCanvas project with an iframe in Spaces.
* [Huggingfab](https://huggingface.co/spaces/pierreant-p/huggingfab): Display a Sketchfab model in Spaces.
* [Diffuse the rest](https://huggingface.co/spaces/huggingface-projects/diffuse-the-rest): Draw and diffuse the rest

## Adding a build step before serving

Static Spaces support adding a custom build step before serving your static assets. This is useful for frontend frameworks like React, Svelte and Vue that require a build process before serving the application. The build command runs automatically when your Space is updated.

Add `app_build_command` inside the `YAML` block at the top of your Spaces **README.md** file, and `app_file`.

For example:
- `app_build_command: npm run build`
- `app_file: dist/index.html`

Example spaces:

- [Svelte App](https://huggingface.co/spaces/julien-c/vite-svelte)
- [React App](https://huggingface.co/spaces/coyotte508/static-vite)


Under the hood, it will [launch a build](https://huggingface.co/spaces/huggingface/space-build), storing the generated files in a special `refs/convert/build` ref.

## Space variables

Expand Down