ionic-team / ionic-team/ionic-cli

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

Open
#4,653 13 comments 9 reactions 0 assignees View on GitHub
triage
Dominant language
TypeScript
Stars
2k
Forks
682
PR merge metrics
No merged PRs in 30d

Description

**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](https://capacitorjs.com/docs/v3/config) (`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](https://capacitorjs.com/docs/v3/config), 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

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.