Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Support custom builder in cordova-serve #108

Closed
doug-a-brunner opened this issue Mar 27, 2019 · 10 comments
Closed

Support custom builder in cordova-serve #108

doug-a-brunner opened this issue Mar 27, 2019 · 10 comments

Comments

@doug-a-brunner
Copy link

doug-a-brunner commented Mar 27, 2019

In the resolution of issue #32 the capability was added to use browserTarget to specify an arbitrary builder that the cordova-build builder wraps. It would be very helpful to have the analogous capability for cordova-serve: rather than hardcoding DevServerBuilder and extending it, use getBuilder to pick up a specified builder.

It looks, however, like this might not be possible with Angular Architect as it stands now: their DevServerBuilder seems to be grabbing the browser build options out of the specified browserTarget, and doing so internally within run(). That would make an override of buildWebpackConfig() the only place where the browser build options are accessible to modify...and this is not part of the Builder<> interface, only of DevServerBuilder, so this strategy doesn't work for an arbitrary Builder loaded by Architect.

Does this seem right - and if so, is there any resolution coming with the new Angular build API? I haven't been able to find any documentation on the new API, so hard to tell what might be changing with it. This problem throws a bit of a wrench into my development, because my project (which builds for both Cordova and Electron with a single codebase) relies on a custom webpack config to ignore imports of node-provided modules like fs when building for Angular.

@bobrosoft
Copy link

bobrosoft commented May 31, 2019

I think I have related issue. Just added support for custom webpack configuration using that article https://www.techiediaries.com/ionic-angular-typeorm-custom-webpack-configuration/ and have it working for ionic serve but not with ionic serve --devapp because second is using ionic-cordova-serve architect builder which looks as not picking up next correct builder in the chain but ionic-cordova-build does it as I see.

@mhartington
Copy link
Contributor

Hi there! Is this still an issue?With the latest updates to the new builder API, this should be supported as the browserBuild is an option that can be passed

          "options": {
            "cordovaBuildTarget": "app:ionic-cordova-build",
            "devServerTarget": "app:serve"
          },

@bobrosoft
Copy link

@mhartington working now! Good job 👍👍👍

@doug-a-brunner
Copy link
Author

@mhartington, I don't fully understand your comment. When you say browserBuild, where does that get specified and what sort of values does it take? I grepped through a freshly created Ionic example app, and only saw browserBuild used as a variable name in angular-toolkit, not in any schema or config file. (A tabs app created from the CLI right now has a schema path in its angular.json that no longer exists, making it hard to follow a trail.) I haven't been able to find any documentation on this so far - is there some that I'm missing?

@mhartington
Copy link
Contributor

Sorry, browserBuild was the incorrect word. In the ionic-cordova-serve builder, you can pass 2 options, the browser build task, and the dev server task

        "ionic-cordova-serve": {
          "builder": "@ionic/angular-toolkit:cordova-serve",
          "options": {
            "cordovaBuildTarget": "app:ionic-cordova-build",
            "devServerTarget": "app:serve"
          },

These could be any task in your angular.json. For example, the default "cordovaBuildTarget": "app:ionic-cordova-build", will point to the browserTarget for ionic-cordova-build builder.

        "ionic-cordova-build": {
          "builder": "@ionic/angular-toolkit:cordova-build",
          "options": {
            "browserTarget": "app:build"
          },
          "configurations": {
            "production": {
              "browserTarget": "app:build:production"
            }
          }
        },

Which in turn resolves to the default build task for the app.

If you wanted to customize this, you could do the following.

  • Customize the build task in the angular.json
  • Customize the browserTarget option in ionic-cordova-build.

@osben
Copy link

osben commented Jul 18, 2020

please add support custom-webpack

@lucashsilva
Copy link

I am facing the same issue. My webpack configuration from build task is ignored by ionic-cordova-serve task.

@freedom-git
Copy link

Same issue, is there a solution?

@mhartington
Copy link
Contributor

Going to close this. As I mentioned here #230 (comment)

We need to be explicit about what kind of builder we trigger.

@Bishop19
Copy link

HI! Any updates on this? I'm really struggling on this 😞

@ionic-team ionic-team locked and limited conversation to collaborators Oct 19, 2021
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

7 participants