Search code examples
angularweb-componentangular-components

angular production build not bootstrapping when wrapping angular element


I have created angular element using angular 7 and tested standalone with an html file (after including element JS file ) which is working fine.

It is also working fine, when I include Angular element in other Angular 7 project and running local setup using ng server.

Whenever I build the angular project with the --prod and try to run the application, the parent application is not bootstrapping.

When I remove the element js reference and custom html and build the application using --prod, application bootstrap/ run perfectly.

I am using angular 7.2 to build both web-component/element and application.

I need help to identify why the application is not running/bootstrapping along with the angular element.


Solution

  • While troubleshooting the issue come across the blog : https://medium.com/swlh/multiple-angular-apps-on-a-single-page-9f49bc863177

    I went with option 3 (as already binding element inside angular application) :Ngx Build Plus

    the only thing you need to take care is to install appropriate version of build plus, I used ng add ngx-build-plus@7

    install the ngx-build in both the project and set different jsonpFunction has resolved the issue.