Monday, 9 July 2018

Integrated web component uses wrong base-href in Angular 6

I just created my first web-component using Angular 6. Everything worked fine, until I tried to integrate the web component into an existing application:

Application that integrates web component (https://www.example.com):

<script type="text/javascript" src="https://component.example.com/html-imports.min.js"></script>
<link rel="import" href="https://component.example.com/element.html">
<my-web-component uuid="2342-asdf-2342-ffsk"></my-web-component>

My web component index.html does not contain a base-href.

The browser now tries to load the assets of the web component:

https://www.example.com/assets/i18n/de_CH.json

instead

 https://component.example.com/assets/i18n/de_CH.json

When I try to add the base-href during the build, it results in this:

ng build --configuration=development --base-href https://component.example.com/

Cannot read property 'startTag' of null          
TypeError: Cannot read property 'startTag' of null
    at IndexHtmlWebpackPlugin.<anonymous> (/home/www-data/.../node_modules/@angular-devkit/build-angular/src/angular-cli-files/plugins/index-html-webpack-plugin.js:147:62)
    at Generator.next (<anonymous>)
    at fulfilled (/home/www-data/.../node_modules/@angular-devkit/build-angular/src/angular-cli-files/plugins/index-html-webpack-plugin.js:4:58)

Any help is really appreciated, I am running out of ideas.



from Integrated web component uses wrong base-href in Angular 6

No comments:

Post a Comment