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.
A few tips first:
<base>
already in the <head>
since all of them share the same starting URL. Also, it does not make sense to use both relative and absolute URLs in this case.--base-href
configuration can even override the one in HTML so don't worry. type
in script
tag, it's definitely not Javascript and it's not necessary.Final look:
<base href="https://component.example.com/">
<script src="html-imports.min.js"></script>
<link rel="import" href="element.html">
<my-web-component uuid="2342-asdf-2342-ffsk"></my-web-component>
Back to the problem, can you give me a fiddle of your component source code? The problem may lie within the way you load files inside the component, not the way you import the component, nor the code in here.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With