Webpack 2 Angular 1 个模板加载器?

Webpack 2 Angular 1 template loader?

由于 webpack 2 引入了 ES6 模块系统,require('./mytemplate.html') 语法在基于 angular 1 和 webpack 2 的项目中不起作用。

无法找到与 webpack 2 一起加载 html 模板的加载器。

使用 webpack2 加载 angular1 模板文件的正确方法是什么?

注意:我正在使用打字稿 类 创建 angular 1 个组件,这些组件具有模板:require('./mytemplate.html') 属性。举个例子。

export class MyComponent implements ng.IComponentOptions {
    public template: string = require('./mytempalte.html');
    public controller = MyControllerClass;
}

到目前为止,webpack 2 仍然支持 require 语法。对我有用的是安装节点类型:

@types/node

这消除了我在需要模板时遇到的错误,例如

export class AdminComponent implements ng.IComponentOptions {
    public template: string = require('./admin.component.html');
    public controller = AdminComponentController;
}

尽管如此,仍在使用 html-loader 来加载这些模板。