Skip to content

Commit 0442bc7

Browse files
coyotte508Copilotgary149julien-c
authored
Static space build docs (#1742)
* static space build docs * typo * Update docs/hub/spaces-config-reference.md Co-authored-by: Copilot <[email protected]> * Update docs/hub/spaces-sdks-static.md Co-authored-by: Victor Muštar <[email protected]> * Update docs/hub/spaces-sdks-static.md Co-authored-by: Victor Muštar <[email protected]> * Update docs/hub/spaces-config-reference.md Co-authored-by: Julien Chaumond <[email protected]> * Update docs/hub/spaces-sdks-static.md Co-authored-by: Julien Chaumond <[email protected]> * Update docs/hub/spaces-sdks-static.md Co-authored-by: Victor Muštar <[email protected]> * Update docs/hub/spaces-sdks-static.md Co-authored-by: Julien Chaumond <[email protected]> * Update docs/hub/spaces-config-reference.md Co-authored-by: Julien Chaumond <[email protected]> * Update docs/hub/spaces-sdks-static.md --------- Co-authored-by: Copilot <[email protected]> Co-authored-by: Victor Muštar <[email protected]> Co-authored-by: Julien Chaumond <[email protected]>
1 parent 0a2e25a commit 0442bc7

File tree

2 files changed

+27
-0
lines changed

2 files changed

+27
-0
lines changed

docs/hub/spaces-config-reference.md

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -49,6 +49,14 @@ Value must be one of `"small"`, `"medium"` or `"large"`.
4949
Path to your main application file (which contains either `gradio` or `streamlit` Python code, or `static` html code).
5050
Path is relative to the root of the repository.
5151

52+
**`app_build_command`** : _string_
53+
For static Spaces, command to run first to generate the HTML to render. Example: `npm run build`.
54+
55+
This is used in conjunction with `app_file` which points to the built index file: e.g. `app_file: dist/index.html`.
56+
57+
Each update, the build command will run in a Job and the build output will be stored in `refs/convert/build`,
58+
which will be served by the Space. See an example at https://huggingface.co/spaces/coyotte508/static-vite
59+
5260
**`app_port`** : _int_
5361
Port on which your application is running. Used only if `sdk` is `docker`. Default port is `7860`.
5462

docs/hub/spaces-sdks-static.md

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,25 @@ Here are some examples of Spaces using custom HTML:
66

77
* [Smarter NPC](https://huggingface.co/spaces/mishig/smarter_npc): Display a PlayCanvas project with an iframe in Spaces.
88
* [Huggingfab](https://huggingface.co/spaces/pierreant-p/huggingfab): Display a Sketchfab model in Spaces.
9+
* [Diffuse the rest](https://huggingface.co/spaces/huggingface-projects/diffuse-the-rest): Draw and diffuse the rest
10+
11+
## Adding a build step before serving
12+
13+
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.
14+
15+
Add `app_build_command` inside the `YAML` block at the top of your Spaces **README.md** file, and `app_file`.
16+
17+
For example:
18+
- `app_build_command: npm run build`
19+
- `app_file: dist/index.html`
20+
21+
Example spaces:
22+
23+
- [Svelte App](https://huggingface.co/spaces/julien-c/vite-svelte)
24+
- [React App](https://huggingface.co/spaces/coyotte508/static-vite)
25+
26+
27+
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.
928

1029
## Space variables
1130

0 commit comments

Comments
 (0)