ionic-team / ionic-team/ionic-cli
Capacitor 3 live reload with capacitor.config.ts not working
- 主要語言
- TypeScript
- 星號
- 2k
- 分支
- 682
- PR 合併指標
- 30 天內沒有已合併 PR
描述
**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
貢獻指南
研究方向
先閱讀 packages/@ionic/cli/src/lib/integrations/capacitor/config.ts 和 packages/@ionic/cli/src/commands/deploy/manifest.ts,其中 capacitor.config.json 被硬式編碼。使用 capacitor.config.ts 透過 ionic cap run android -l --external 重現此問題。當 live-reload 伺服器參數能夠傳遞至 Android 和 iOS 建置,且不會建立互相競爭的 JSON 設定時,即表示完成。
由索引模型根據 Issue 內容生成。
評估
- 技術堆疊
- typescript
- 領域
- cli
- Issue 類型
- 缺陷
- 難度
- 2/5
- 預估耗時
- 1-3 小時
- 活躍度
- 停滯
- 描述清晰度
- 描述清楚
- 新手友好度
- 45/100