You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Add documentation for web commands to README (#223)
# Objective
Closes#204.
It's currently hard for users to discover how to use the web-specific
functionality of the CLI.
As a first step, we should expand the README to give an overview of the
provided features.
# Solution
- Add installation instructions
- Add an overview of the main features and configuration options
The CLI makes it easy to build and run web apps made with Bevy, using `bevy build web` and `bevy run web`.
28
+
It takes care of compiling the app to Wasm, creating JavaScript bindings and serving it on a local web server to test it out.
29
+
Necessary tools will also be installed automatically.
30
+
31
+
> [!NOTE]
32
+
>
33
+
> The arguments you know from `cargo` (like `--release`) must be placed before the `web` subcommand, while the web-specific options (like `--open`) must be placed afterwards, e.g.
34
+
>
35
+
> ```cli
36
+
> bevy run --release web --open
37
+
> ```
38
+
39
+
### Running in the browser
40
+
41
+
Use the `bevy run web` command to run your app in the browser.
42
+
The app will be automatically served on a local web server, use the `--open` flag to automatically open it in the browser.
43
+
44
+
The server will provide a default `index.html` serving as entrypoint for your app.
45
+
It features a loading screen and some other utilities.
46
+
If you want to customize it, simply create a `web/index.html` file to override the default behavior.
47
+
Other files in the `web` folder will also be included in your application.
48
+
49
+
### Creating web bundles
50
+
51
+
To deploy your app on a web server, it's often necessary to bundle the binary, assets and web files into a single folder.
52
+
Using `bevy build web --bundle`, the CLI can create this bundle for you automatically.
53
+
It will be available in the `target/bevy_web` folder, see the command's output for the full file path.
54
+
55
+
### Compilation profiles
56
+
57
+
Web apps have different needs than native builds when it comes to compilation.
58
+
For example, binary size is a lot more important for web apps, as it has a big influence on the loading times.
59
+
60
+
The Bevy CLI provides custom `web` and `web-release` compilation profiles, which are optimized for web apps.
61
+
They are used by default for the web sub-commands (depending on the `--release` flag).
62
+
63
+
The profiles can be customized as usual in `Cargo.toml`:
64
+
65
+
```toml
66
+
[profile.web-release]
67
+
inherits = "release"
68
+
opt-level = "z"
69
+
```
70
+
71
+
Alternatively, you can change the profile entirely, e.g. `bevy run --profile=foo web`.
72
+
73
+
### Usage in CI
74
+
75
+
The CLI may include interactive prompts if parts of the required tooling is not installed on the system.
76
+
These prompts will break your pipeline if they are triggered in CI.
77
+
78
+
To avoid this problem, use the `--yes` flag to automatically confirm the prompts:
0 commit comments