-
Notifications
You must be signed in to change notification settings - Fork 8
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
Bevy run #120
Bevy run #120
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Great! I have a few nits, but feel free to merge this once you feel it is ready.
src/run/mod.rs
Outdated
wasm_bindgen::bundle(&package_name()?, args.profile())?; | ||
|
||
let port = web_args.port; | ||
let url = format!("http://127.0.0.1:{port}"); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I've had situations where https
on localhost
was necessary for development of a project. Do you think it would be nice to have the option here?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
In my experience, setting up HTTPS is not worth it for a development server such as this. The primary purpose of TLS is to secure communication across untrusted networks, but 127.0.0.1
is completely local, so there's no network to worry about. bevy run web
is not meant for production. In those cases you build everything ahead of time and serve it with something like Nginx, which implements TLS already.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is it possible to create a valid certificate for localhost
to enable HTTPS?
I'd say that when we need it, we can create a follow-up issue to enable that functionality :)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes, assuming openssl or the like is installed. We can leave it to the user to create their own self signed cert. It's a common step for web developers and is usually its own step outside of other tooling.
Add a
bevy run
command which conveniently runs your Bevy app.It mostly wraps
cargo run
, but also provides aweb
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 inbevy_quickstart
.This is the last part of #24.
Closes #8.
Testing
bevy-run
branch.cargo install --path .
to install this version of the Bevy CLI.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 fortrunk
, it might also not work out of the box. You can try removing the entireweb
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