ionic-team / ionic-team/ionic-cli

Support setting additional ng parameters via command line arguments for ionic cordova run

未关闭
#4,597 1 条评论 0 个 reaction 已指派 0 人 在 GitHub 查看
enhancement project type: angular
主要语言
TypeScript
星标
2k
派生
682
PR 合并指标
30 天内没有已合并 PR

描述

# Come context
A few weeks ago, I flagged an issue with @angular/cli related to passing multiple configurations at the same time when running `ng serve`. Basically, this `ng build -c=foo,bar` would build using the bar config applied on top of the foo config, as expected, but `ng serve -c=foo,bar` wouldn't.

The reason why this happens is the `ng serve` configs actually only have a single parameter (`browserTarget`) which is set to `app:build:foo` and `app:build:bar` respectively. In the end, the multiple config parameters where taken into account correctly, it's just that you end up overriding the entire target and not specific parameters within that target.

In the end, the solution is to use `--browserTarget=app:build:foo,bar` directly in the command line instead of going through a configuration in the angular.json file.

All the details of that discussion here: https://github.com/angular/angular-cli/issues/19013

# The problem
I love `ionic cordova run` but I have a problem with it. I have to support both modern and older devices. Because of a limitation in @angular/cli, [differential loading](https://angular.io/guide/deployment#differential-loading) will not work with `ng serve`. This means that I need to use `--browserTarget=app:build:dev,es5` to patch my build target with an es5 typescript config every time I want to test on those older devices.

Currently, there is no way to provide this argument to @angular/cli with `ionic cordova run`. The documentation suggests that it might be possible to provide additional arguments if you use `ionic serve` instead. This works, but makes the whole development cycle a lot more convoluted as I have to start a server using a proper url (can't use localhost even on an emulator), then build an app that targets that url and publish it to my device. While this can be scripted, it isn't convenient.

More on differential loading's support in ng serve: https://github.com/angular/angular-cli/issues/14455

# The suggestion
Like @angular/cli, I wish that `ionic cordova` let me set parameters like `browserTarget`, and maybe even other ones likes `aot` directly from the command line, which are all already parameters in the angular.json file's ionic-cordova-serve section.

This would make the whole experience a whole lot simpler and would make that tool a lot more powerful. You wouldn't need to fallback to `ionic serve` manually anymore and instead could do something like this:

```> ionic cordova run android --emulator --target=Pixel_2_API_24 --ng --livereload --browserTarget=dev,es5 --other-ng-flags -- --keystore=... --other-cordova-flags```

I have to say, I am not a fan of that syntax, but it's the only way I could make it work with `--` already being taken for the cordova cli. This is still just a suggestion though so feel free to change it as you wish, but keep in mind that there is a definitive use to those additional ng arguments that the tool currently doesn't provide.

贡献指南

打开贡献指南

评估

这个 Issue 还没有评估数据。

把新 issue 发到你的邮箱

精选适合新手参与的 GitHub issue 摘要。