如何使ngtemplate-loader与Webpack 3,Angular 1,TypeScript和ES 6模块一起使用? [英] How to get ngtemplate-loader working with Webpack 3, Angular 1, TypeScript and ES 6 modules?
问题描述
我正在尝试将ngtemplate-loader配置为能够在TypeScript文件中使用我的角度模板,如下所示:
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,
});
webpack.config中的加载程序定义:
Loader definition in webpack.config:
module: {
rules: [
// Angular Template HTML
{
test: /\.thtml$/,
use: [
{
loader: 'ngtemplate-loader',
},
{
loader: 'html-loader',
}
],
},
(奇怪的* .ththml后缀就是这样,没有标准的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).
我尝试添加
options: {
exportAsEs6Default: true
}
链接到链接的html-loader,但这也行不通.
to the chained html-loader, but that did not work out, too.
完整的示例项目: https://github.com/eekboom/ng-webpack
推荐答案
它看起来像是ngtemplate-loader中的错误/缺失功能.
Looks like it is a bug/missing feature in ngtemplate-loader.
我创建了一个问题:
https://github.com/WearyMonkey/ngtemplate-loader/issues/63
和修复它的拉取请求
https://github.com/WearyMonkey/ngtemplate-loader/pull/64
希望它很快会被接受.现在,我可以将package.json指向包含我的fork中的修复程序的提交.
Hope it gets accepted soon. For now I can point my package.json to the commit containing the fix in my fork.
这篇关于如何使ngtemplate-loader与Webpack 3,Angular 1,TypeScript和ES 6模块一起使用?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!