fix(cli): respect server config for host and port during live reload#8380
Open
fabiomartino wants to merge 1 commit intoionic-team:mainfrom
Open
fix(cli): respect server config for host and port during live reload#8380fabiomartino wants to merge 1 commit intoionic-team:mainfrom
fabiomartino wants to merge 1 commit intoionic-team:mainfrom
Conversation
This file contains hidden or 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
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.
Description
This PR implements a robust configuration inheritance system for the
npx cap run --live-reloadcommand. It allows the CLI to automatically detect and use thehostname,url, andportdefined in thecapacitor.config.tsfile when they are not explicitly provided via command-line arguments.Additionally, it ensures that the temporary server configuration generated for live reload is merged with the existing user configuration rather than overwriting it, preserving critical settings like custom schemes (e.g.,
androidSchemeoriosScheme).Change Type
Rationale / Problems Fixed
As detailed in #8303, the current CLI behavior forces a default port of
3000and ignores user-defined server settings during live reload. This creates significant friction for developers using modern bundlers (like Vite on5173) who must manually pass flags for every run.Key fixes in this PR:
server.hostnameandserver.port(or parsesserver.url) as a secondary priority after CLI flags.livereload.ts, settings likeandroidSchemeoriosSchemeare no longer lost when live reload is active.portproperty to theCapacitorConfiginterface indeclarations.ts, which was previously supported by the runtime but missing from the types.Fixes #8303
Tests or Reproductions
Tested manually in a Capacitor + Vite project:
server: { port: 5173 }incapacitor.config.ts.npx cap run android -lwithout specifying--port.5173.--port 8080is passed via CLI, it correctly takes precedence over the config file.androidScheme: 'https'in the config remains present in the temporary native config during the session.Screenshots / Media
N/A
Platforms Affected
Notes / Comments
This PR provides a comprehensive fix for the issues described in #8303 and offers a more complete architectural solution than #8376 by aligning with the "Single Source of Truth" principle (respecting the project's centralized configuration).