Skip to content
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

Open
wants to merge 11 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 8 additions & 8 deletions .github/workflows/release.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ on:
workflow_dispatch:
inputs:
version:
description: 'Version number in the format `v1.2.3`'
description: "Version number in the format `v1.2.3`"
required: true
type: string

Expand Down Expand Up @@ -159,15 +159,15 @@ jobs:
- name: Prepare output directories
run: rm -rf tmp; mkdir -p tmp/binary '${{ env.app }}'

- name: Install cargo-binstall (Web)
- name: Install and run Bevy CLI (Web)
if: ${{ matrix.platform == 'web' }}
uses: cargo-bins/[email protected]
run: |
cargo install --git=https://github.com/TheBevyFlock/bevy_cli --locked bevy_cli
bevy build --locked --release --yes web --bundle

- name: Install and run trunk (Web)
- name: Move web bundle (Web)
if: ${{ matrix.platform == 'web' }}
run: |
cargo binstall --no-confirm trunk wasm-bindgen-cli wasm-opt
trunk build --locked --release --dist '${{ env.app }}'
run: mv 'target/bevy_web/web-release/${{ env.cargo_build_binary_name }}' '${{ env.app }}'

- name: Build binaries (non-Web)
if: ${{ matrix.platform != 'web' }}
Expand Down Expand Up @@ -266,7 +266,7 @@ jobs:
runs-on: ubuntu-latest
steps:
- name: Do nothing
run: 'true'
run: "true"
outputs:
target: ${{ env.upload_to_itch }}

Expand Down
12 changes: 6 additions & 6 deletions .github/workflows/release.yaml.template
Original file line number Diff line number Diff line change
Expand Up @@ -168,15 +168,15 @@ jobs:
- name: Prepare output directories
run: rm -rf tmp; mkdir -p tmp/binary '${{ env.app }}'

- name: Install cargo-binstall (Web)
- name: Install and run Bevy CLI (Web)
if: ${{ matrix.platform == 'web' }}
uses: cargo-bins/[email protected]
run: |
cargo install --git=https://github.com/TheBevyFlock/bevy_cli --locked bevy_cli
bevy build --locked --release --yes web --bundle

- name: Install and run trunk (Web)
- name: Move web bundle (Web)
if: ${{ matrix.platform == 'web' }}
run: |
cargo binstall --no-confirm trunk wasm-bindgen-cli wasm-opt
trunk build --locked --release --dist '${{ env.app }}'
run: mv 'target/bevy_web/web-release/${{ env.cargo_build_binary_name }}' '${{ env.app }}'

- name: Build binaries (non-Web)
if: ${{ matrix.platform != 'web' }}
Expand Down
37 changes: 13 additions & 24 deletions .vscode/tasks.json
Original file line number Diff line number Diff line change
Expand Up @@ -13,9 +13,7 @@
"presentation": {
"clear": true
},
"problemMatcher": [
"$rustc"
],
"problemMatcher": ["$rustc"],
"group": {
"kind": "build",
"isDefault": true
Expand All @@ -25,25 +23,18 @@
"label": "Run native release",
"type": "cargo",
"command": "run",
"args": [
"--release",
"--no-default-features"
],
"args": ["--release", "--no-default-features"],
"presentation": {
"clear": true
},
"problemMatcher": [
"$rustc"
],
"problemMatcher": ["$rustc"],
"group": "build"
},
{
"label": "Run web dev",
"type": "process",
"command": "trunk",
"args": [
"serve"
],
"command": "bevy",
"args": ["run", "--yes", "--no-default-features", "web"],
"options": {
"env": {
"RUST_BACKTRACE": "full"
Expand All @@ -52,27 +43,25 @@
"presentation": {
"clear": true
},
"problemMatcher": [
"$rustc"
],
"problemMatcher": ["$rustc"],
"group": "build"
},
{
"label": "Run web release",
"type": "process",
"command": "trunk",
"command": "bevy",
"args": [
"serve",
"run",
"--yes",
"--release",
"--no-default-features"
"--no-default-features",
"web"
],
"presentation": {
"clear": true
},
"problemMatcher": [
"$rustc"
],
"problemMatcher": ["$rustc"],
"group": "build"
}
]
}
}
25 changes: 0 additions & 25 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -61,28 +61,3 @@ opt-level = 3
# Remove expensive debug assertions due to <https://github.com/bevyengine/bevy/issues/14291>
[profile.dev.package.wgpu-types]
debug-assertions = false

# The default profile is optimized for Wasm builds because
# that's what [Trunk reads](https://github.com/trunk-rs/trunk/issues/605).
# Optimize for size in the wasm-release profile to reduce load times and bandwidth usage on web.
[profile.release]
# Compile the entire crate as one unit.
# Slows compile times, marginal improvements.
codegen-units = 1
# Do a second optimization pass over the entire program, including dependencies.
# Slows compile times, marginal improvements.
lto = "thin"
# Optimize with size in mind (also try "z", sometimes it is better).
# Slightly slows compile times, great improvements to file size and runtime performance.
opt-level = "s"
# Strip all debugging information from the binary to slightly reduce file size.
strip = "debuginfo"

# Override some settings for native builds.
[profile.release-native]
# Default to release profile values.
inherits = "release"
# Optimize with performance in mind.
opt-level = 3
# Keep debug information in the binary.
strip = "none"
25 changes: 0 additions & 25 deletions Cargo.toml.template
Original file line number Diff line number Diff line change
Expand Up @@ -61,28 +61,3 @@ opt-level = 3
# Remove expensive debug assertions due to <https://github.com/bevyengine/bevy/issues/14291>
[profile.dev.package.wgpu-types]
debug-assertions = false

# The default profile is optimized for Wasm builds because
# that's what [Trunk reads](https://github.com/trunk-rs/trunk/issues/605).
# Optimize for size in the wasm-release profile to reduce load times and bandwidth usage on web.
[profile.release]
# Compile the entire crate as one unit.
# Slows compile times, marginal improvements.
codegen-units = 1
# Do a second optimization pass over the entire program, including dependencies.
# Slows compile times, marginal improvements.
lto = "thin"
# Optimize with size in mind (also try "z", sometimes it is better).
# Slightly slows compile times, great improvements to file size and runtime performance.
opt-level = "s"
# Strip all debugging information from the binary to slightly reduce file size.
strip = "debuginfo"

# Override some settings for native builds.
[profile.release-native]
# Default to release profile values.
inherits = "release"
# Optimize with performance in mind.
opt-level = 3
# Keep debug information in the binary.
strip = "none"
10 changes: 6 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -48,18 +48,20 @@ Feel free to move things around however you want, though.

## Run your game

We recommend running your game with the [Bevy CLI](https://github.com/TheBevyFlock/bevy_cli).

Running your game locally is very simple:

- Use `cargo run` to run a native dev build.
- Use [`trunk serve`](https://trunkrs.dev/) to run a web dev build.
- Use `bevy run` to run a native dev build.
- Use `bevy run --no-default-features web` to run a web dev build.

If you're using [VS Code](https://code.visualstudio.com/), this template comes with a [`.vscode/tasks.json`](./.vscode/tasks.json) file.

<details>
<summary>Run release builds</summary>

- Use `cargo run --profile release-native --no-default-features` to run a native release build.
- Use `trunk serve --release --no-default-features` to run a web release build.
- Use `bevy run --release --no-default-features` to run a native release build.
- Use `bevy run --release --no-default-features web` to run a web release build.

</details>

Expand Down
15 changes: 0 additions & 15 deletions Trunk.toml

This file was deleted.

1 change: 0 additions & 1 deletion post-generate.rhai
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
// Rename template files.
file::rename(".github/workflows/release.yaml.template", ".github/workflows/release.yaml");
file::rename("Cargo.toml.template", "Cargo.toml");
file::rename("web/index.html.template", "web/index.html");
file::rename("src/main.rs.template", "src/main.rs");
file::rename("src/lib.rs.template", "src/lib.rs");
file::rename("src/audio.rs.template", "src/audio.rs");
Expand Down
2 changes: 0 additions & 2 deletions src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -38,9 +38,7 @@ impl Plugin for AppPlugin {
.set(WindowPlugin {
primary_window: Window {
title: "Bevy New 2D".to_string(),
canvas: Some("#bevy".to_string()),
fit_canvas_to_parent: true,
prevent_default_event_handling: true,
..default()
}
.into(),
Expand Down
38 changes: 0 additions & 38 deletions web/index.html

This file was deleted.

41 changes: 0 additions & 41 deletions web/index.html.template

This file was deleted.

57 changes: 0 additions & 57 deletions web/restart-audio-context.js

This file was deleted.

Loading