Webpack通過在dist文件夾中生成'js'來編譯'typescript'文件。 我發現的WebPack正在改變這一切 'templateurl' 像這樣的 '樣板':如何通過保留'templateurl'來編譯角度2 webpack如同
我的打字稿組件:
@Component({
selector: 'app',
encapsulation: ViewEncapsulation.None,
templateUrl: 'app.html', // <----------------------
directives: [HeaderComponent, SideBar],
})
下面自動生成的編譯JS組件
App = __decorate([
core_1.Component({
selector: 'app',
encapsulation: core_1.ViewEncapsulation.None,
template: __webpack_require__(718),// <----------
directives: [header_component_1.HeaderComponent, sidebar_component_1.SideBar],
}),
__metadata('design:paramtypes', [(typeof (_a = typeof app_service_1.AppState !== 'undefined' && app_service_1.AppState) === 'function' && _a) || Object])
], App);
我想要什麼要做的只是在生成的文件中繼續使用'templateUrl'。
我使用asp.net mvc,我有很多CSHTML文件,我想繼續使用它。我想改變webpack編譯'ts'的方式,並忽略'取得html內容'的想法。所以我期待:
App = __decorate([
core_1.Component({
selector: 'app',
encapsulation: core_1.ViewEncapsulation.None,
templateUrl: 'app.html', // <----------------------
directives: [header_component_1.HeaderComponent, sidebar_component_1.SideBar],
}),
__metadata('design:paramtypes', [(typeof (_a = typeof app_service_1.AppState !== 'undefined' && app_service_1.AppState) === 'function' && _a) || Object])
], App);
我試圖像這樣手動更改自動生成的文件。它的工作原理。 我想保留templateUrl。