Angular2与webpack生成:"无法加载app / app.component.html"

时间:2016-07-19 20:20:53

标签: angular webpack

我的项目基于Angular2-webpack-starter。它目前位于Angular2 rc.4webpack 1.13.1。如果我在开发模式下运行它,一切都运行良好。

dev mode result

但是如果在生产模式下运行,由于Failed to load app/app.component.html,我会收到GET http://localhost:8080/app/app.component.html 404 (Not Found)异常。

enter image description here

我查看了webpack.common.jswebpack.dev.jswebpack.prod.js个文件。 prod配置没有什么特别之处,html加载器实际上位于共享webpack.common.js文件中。我正在寻求有关如何调试此问题的帮助。

1 个答案:

答案 0 :(得分:4)

angular2-webpack-starter使用angular2-template-loader来跟踪html和样式依赖关系,据我所知,最终会将组件中的templateUrl:属性更改为{{1属性并实际内联HTML文件。所以你的应用程序甚至不应该调用html文件。您是否更改了公共配置文件以删除template:?它位于公共配置(https://github.com/AngularClass/angular2-webpack-starter/blob/master/config/webpack.common.js)的第143行。

还要确保为真棒加载器正确设置了tsconfig.json,因为angular2-template-loader需要将angular2-template-loader属性设置为true。请参阅此处(在“要求”下):https://github.com/TheLarkInn/angular2-template-loader

相关问题