Running Quasar dev server in Capacitor mode withquasar dev -m capacitor -T android results in the dialog to choose external IP address:
? What external IP should Quasar use? 192.168.0.3
App • Updated src-capacitor/package.json
App • Updated capacitor.config.json
App • Running "...\node_modules\@capacitor\cli\bin\capacitor sync android" in ...
The problem is that this updates src-capacitor/capacitor.config.json with local information that can be accidentally pushed, which is never desirable:
"server": {
"androidScheme": "https",
"url": "http://192.168.0.3:9500" <-- this line is added
}
Not to mention that most times it would be practical to skip this dialog, as the application runs locally and can safely use localhost instead of external IP.
As loosely described in the documentation, this seems to be the expected behaviour but not desirable one.
How can updating server.url in capacitor.config.json be avoided?
That is why your actual config files should remain private (not tracked by Git).
You should only track config file values, plus a config file template
Then, you can use a content filter driver, using
.gitattributesdeclaration.The script generate the right
jsonfile by replacing placeholder values with the fixed value"url": "http://192.168.0.3:9500"each time you checkout a branch, when the smudge script detects a local development environment.The generated actual
confremains ignored (by the.gitignore).No synchronization issue during merges.
The smudge script selects the correct value file and generates the correct
jsonbased on the template the smudge script is applied to during agit switch(or oldgit checkout).See a content driver setup example at "git smudge/clean filter between branches".
Your
.gitattributeswould includesrc-capacitor/capacitor.config.json filter=smudgeScriptWith
smudgeScript(here, I simulate the logic which detects you are in a "devServer" with a hypotheticalENVvariable):The alternative is to code that logic in the
quasar.conf.jsThat would set a static URL in your
quasar.conf.js. Inside the devServer property, specify a public property with your desired URL. You need to add the logic which detects you are in a "devServer".True, and using the first approach, where
src-capacitor/capacitor.config.jsonis ignore, will allow you to specify what you need in it, without risking to add/commit/push said modification.