question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Capacitor 3 live reload with capacitor.config.ts not working

See original GitHub issue

Description:

Ionic and Capacitor have built-in support for live reload: https://capacitorjs.com/docs/v3/guides/live-reload#using-with-ionic-cli. The live reload functionality leverages the capacitor.config.json file to set the server parameter, so that the Android and iOS builds know which server to use for live reload.

Capacitor v3 (currently in beta) adds support for a TypeScript configuration file (capacitor.config.ts). However, Ionic has capacitor.config.json hardcoded in two places:

https://github.com/ionic-team/ionic-cli/blob/85097593e45837e1a0bdef8f3e20a5f44f6cd1e6/packages/%40ionic/cli/src/lib/integrations/capacitor/config.ts#L4

https://github.com/ionic-team/ionic-cli/blob/77b02a39d08fb369c6b95b5f3b0c255370e9fc23/packages/%40ionic/cli/src/commands/deploy/manifest.ts#L22

Because of this, even if a .ts config file is present, Ionic will write the server parameters to a newly created capacitor.config.json, because of which the config never reaches the android and ios folders. Capacitor prefers the .ts file and therefore doesn’t look for a .json file anymore.

Steps to Reproduce:

  • Install Capacitor 3 beta
  • Ensure you have a TypeScript config file, not a JSON one
  • Run a live reload command, e.g. ionic cap run android -l --external
  • Notice a new file capacitor.config.json is created alongside the existing capacitor.config.ts, therefore the server parameter never reaches the Android and iOS builds

Output:

n/a

My ionic info:

Ionic:

   Ionic CLI                     : 6.12.4 (C:\Users\Dennis\AppData\Roaming\nvm\v14.15.5\node_modules\@ionic\cli)
   Ionic Framework               : @ionic/angular 5.5.5
   @angular-devkit/build-angular : 0.1100.7
   @angular-devkit/schematics    : 11.0.7
   @angular/cli                  : 11.0.7
   @ionic/angular-toolkit        : 2.3.3

Capacitor:

   Capacitor CLI   : 3.0.0-beta.6
   @capacitor/core : 3.0.0-beta.6

Utility:

   cordova-res : not installed
   native-run  : 1.3.0

System:

   NodeJS : v14.15.5 (C:\Program Files\nodejs\node.exe)
   npm    : 6.14.11
   OS     : Windows 10

Other Information:

N/A

Issue Analytics

  • State:open
  • Created 3 years ago
  • Reactions:9
  • Comments:13 (3 by maintainers)

github_iconTop GitHub Comments

1reaction
codercodingthecodecommented, Jul 12, 2021

Furthermore, if you update from 2 to 3 today as I did. You will run into the same issue. The .json file keeps getting recreated instead of using the .ts version with base settings.

From this guide: https://capacitorjs.com/docs/updating/3-0

0reactions
adamschoenemanncommented, Jan 21, 2022

Same problem here (on android, haven’t tried IOS).

Ubuntu 20 Node v16.13.2 NPM 8.1.2 @capacitor/core 3.2.5

Read more comments on GitHub >

github_iconTop Results From Across the Web

Live reload issue after upgrading my app into capacitor 3
Hey developer, just two days before i upgrade my old app into capacitor 3, and during debugging on Android after run command ionic...
Read more >
Live Reload | Capacitor Documentation
This performs an ionic build , copies web assets into the specified native platform, then opens the IDE for your native project (Xcode...
Read more >
Capacitor 3 live reload with capacitor.config.ts not working
Install Capacitor 3 beta; Ensure you have a TypeScript config file, not a JSON one; Run a live reload command, e.g. ionic cap...
Read more >
Capacitor live reload is not working with Angular app
Any clue? I test this on an Android device with OS Android 8.00. I have run the app using ng serve. capacitor.config.json
Read more >
How to run ionic capacitor app from nx monorerepo in live ...
The current implementation of ionic and capacitor cli are not working out of the ... in live reload mode by adding server option...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found