I am trying configure ngtemplate-loader to be able to use my angular template in a TypeScript file like so:
import myTemplateUrl from './hello-angular2-template.thtml';
angular
.module('pd')
.component('helloAngular2', {
templateUrl: myTemplateUrl,
});
Loader definition in webpack.config:
module: {
rules: [
// Angular Template HTML
{
test: /\.thtml$/,
use: [
{
loader: 'ngtemplate-loader',
},
{
loader: 'html-loader',
}
],
},
(The strange *.ththml suffix is just so, that no standard html-loader can interfere.)
However the template never gets loaded (is undefined after import).
I tried to add
options: {
exportAsEs6Default: true
}
to the chained html-loader, but that did not work out, too.
Full example project: https://github.com/eekboom/ng-webpack