-
Notifications
You must be signed in to change notification settings - Fork 31
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Switch from trunk
to bevy run web
#312
Draft
TimJentzsch
wants to merge
2
commits into
TheBevyFlock:main
Choose a base branch
from
TimJentzsch:297-use-bevy-run
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Draft
Conversation
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
TimJentzsch
added a commit
to TheBevyFlock/bevy_cli
that referenced
this pull request
Oct 3, 2024
Add a `bevy run` command which conveniently runs your Bevy app. It mostly wraps `cargo run`, but also provides a `web` sub command, which makes it a lot easier to target the browser. This option will compile your app for WASM, create JS bindings, add an `index.html` file if you don't provide one yourself and serves the build locally to open it in your browser. The default `index.html` file is mostly what we had in `bevy_quickstart`. This is the last part of #24. Closes #8. # Testing 1. Checkout the `bevy-run` branch. 2. Run `cargo install --path .` to install this version of the Bevy CLI. 3. Navigate to your Bevy app. 4. Run `bevy run web`. Note that your app must be compatible with WASM. If you have features or profiles enabled by default which are not compatible with WASM, you need to disable them. E.g. `bevy run --no-default-features web`. If you have a custom `index.html` configured for `trunk`, it might also not work out of the box. You can try removing the entire `web` folder to try the default setup. A good example project is of course `bevy_new_2d`, which you can test on this branch: <TheBevyFlock/bevy_new_2d#312>
This was referenced Dec 23, 2024
TimJentzsch
added a commit
to TheBevyFlock/bevy_cli
that referenced
this pull request
Dec 29, 2024
# Objective Closes #196, unblocks <TheBevyFlock/bevy_new_2d#312>. With `wasm-opt`, we can further increase the performance and reduce the file size of the Wasm binary we use for web builds. This speeds ups the app both in-game and the loading times. # Solution As a simple first solution, we add a hard-coded size optimization pass in release mode. In future PRs, we can make this more configurable. To the user, we log the time the optimization took as well as the file size reduction as percentage. This is behind the `wasm-opt` feature flag (currently disabled by default), to give the user a way to turn this off and because this increases compile times of the CLI quite a bit.
BD103
pushed a commit
to TheBevyFlock/bevy_cli
that referenced
this pull request
Dec 29, 2024
# Objective Closes #68. Adds the `--bundle` argument to the `bevy build web` and `bevy run web` commands. This will pack all files needed for the web into a single folder. The location of the bundle will be `target/bevy_web/{profile}/{binary}`. This makes it a lot easier to deploy the app e.g. on itch.io or a generic web server. It also unblocks the switch from `trunk` to the Bevy CLI for the Bevy 2D template: <TheBevyFlock/bevy_new_2d#312>. # Solution - Add the `--bundle` option to the build and run web commands. - Create a new `WebBundle` enum, which can represent a linked or packed bundle: - A linked bundle is what we use by default, which is optimized for dev. It keeps e.g. the asset folder and WASM artifacts in their place to avoid duplication and copy operations. When running the app, the local web server will "link" together all the files and folders needed to run the app. - A packed bundle is a folder that contains all the necessary web artifacts. They will be copied in the directory. This option is most useful to deploy the web app.
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Closes #297.
This PR prepares the project to use the Bevy CLI, mainly the
bevy run
command.It simplifies especially running for the web target, which previously required use of
trunk
(and a bunch of additional configuration).TODO
The CI builds won't work yet. We probably need TheBevyFlock/bevy_cli#68 to make them work.