Skip to content

Conversation

@musjj
Copy link
Contributor

@musjj musjj commented Oct 18, 2025

Add an option for copying a packed web bundle directory to a user-specified directory. This lets you skip any error-prone parsing/guessing when locating the bundle directory, which is usually useful for CI-related tasks.

The behavior is modeled after the unstable --artifact-dir option from cargo:

Fix: #649

@DaAlbrecht DaAlbrecht added A-Web Building or running Bevy apps targeting the browser D-Straightforward Simple bug fixes and API improvements, docs, test and examples S-Needs-Review The PR needs to be reviewed before it can be merged labels Oct 19, 2025
Copy link
Collaborator

@DaAlbrecht DaAlbrecht left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm open to this but do you think this is still needed even if the Bundle path is part of the API?

pub wasm_opt: Vec<String>,

/// Copy packed bundle directory to this directory
#[arg(long = "bundle-dir", allow_hyphen_values = true)]
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nit: While technically directories could start with a - I think we can avoid problems by not allowing that, what do you think?

Suggested change
#[arg(long = "bundle-dir", allow_hyphen_values = true)]
#[arg(long = "bundle-dir")]

fs::create_dir_all(target).context("failed to create target directory")?;
dir::copy(path, target, &CopyOptions::new().content_only(true))
.context("failed to copy packed bundle directory to target directory")?;
}
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nit: I would like an additional log line that explains that the cli copied the files to the new dir.

cmd.current_dir(test_path()).args([
"build",
"-p=bevy_default",
"--release",
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nit: We could save CI time by not using the release profile here.

@@ -1,3 +1,6 @@
#[cfg(feature = "web")]
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Does it make sense to support this for cargo run?

#[arg(long = "wasm-opt", allow_hyphen_values = true)]
pub wasm_opt: Vec<String>,

/// Copy packed bundle directory to this directory
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
/// Copy packed bundle directory to this directory
/// The directory to copy final packed bundle to. Note that a copy of the Bundle can still be found at `target/bevy_web`.

Copy link
Collaborator

@DaAlbrecht DaAlbrecht left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

My bad, wanted to just leave some comments, didn't mean to approve already

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

A-Web Building or running Bevy apps targeting the browser D-Straightforward Simple bug fixes and API improvements, docs, test and examples S-Needs-Review The PR needs to be reviewed before it can be merged

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Programmatic way to locate web bundle path

2 participants