Default platform setting for multi-target applications
Opened this issue · 1 comments
Feature Request
In multi-target fullstack setups like the template with fullstack enabled the Cargo.toml
must have features for each platform like this:
[features]
desktop = ["dioxus/desktop"]
web = ["dioxus/web"]
mobile = ["dioxus/mobile"]
server = ["dioxus/server"]
During a web
build, two binaries are built: the server with the server
feature enabled and the client with the web
feature enabled.
web
should not be a default feature flag because that would enable the web
feature during the server build. That could cause issues with user code with web-only logic gated behind that flag.
Implement Suggestion
The CLI could read from a default_platform
config with either web, desktop, or mobile to determine what platform to serve if --platform
argument is set
Restore the default_platform
setting that was removed in #2975
There is some interaction here with the default features and rust analyzer. Whatever features we have enabled by default are used by default by rust analyzer. It sounds like the intention in #2975 was to enable a feature by default for rust analyzer. We could enable all features by default for rust analyzer and disable default features in the CLI when we serve, but it makes it more difficult to reason about what features are enabled when you build:
[features]
default = ["desktop", "web", "mobile", "server"]
desktop = ["dioxus/desktop"]
web = ["dioxus/web"]
mobile = ["dioxus/mobile"]
server = ["dioxus/server"]