2

我正在尝试设置一个启用热模块更换的角度 cli 项目。我按照 https://github.com/angular/angular-cli/wiki/stories-configure-hmr中的步骤进行操作, 但是每次更改某些代码时,我的应用程序仍会完全重建。

例如,我有一个由我的 TestModule 声明的 TestComponent。TestModule 由 AppModule 导入。测试组件看起来像这样:

<input type="text"/>

我的 AppComponent 看起来像这样:

<input type="text"/>
<test-component></test-component>

现在,如果我用一些输入填充两个输入字段,然后更改 TestComponent 的代码,启用 hmr,我希望 webpack 只重建 TestComponent,以便 AppComponent 中的输入保持不变。但是,应用程序完全重建,浏览器重新加载,两个输入都消失了。控制台输出表明 webpack 已检测到更改并且 hmr 将被执行。

4

0 回答 0