微信公众号搜"智元新知"关注
微信扫一扫可直接关注哦!

Angular CLI Css Injection而不是重新加载

当我运行服务器时,如果我对.scss文件进行更改,则会导致页面重新加载.这很不方便,可能会丢失一些状态或开发工具更改.

通常当我处理设计时,我使用类似browseryc的东西来注入css而不刷新页面.当我必须调试一些棘手的东西时,这节省了大量的时间.

反正是否有角度cli注入.scss更改或重新加载页面

编辑:

从webpack文档:

HMR is an opt-in feature that only affects modules containing HMR code. One example would be patching styling through the style-loader. In order for patching to work,the style-loader implements the HMR interface; when it receives an update through HMR,it replaces the old styles with the new ones.

Similarly,when implementing the HMR interface in a module,you can describe what should happen when the module is updated. However,in most cases,it’s not mandatory to write HMR code in every module. If a module has no HMR handlers,the update bubbles up. This means that a single handler can update a complete module tree. If a single module from the tree is updated,the entire set of dependencies is reloaded.

从我听到的Angular-CLI支持HMR,但我找不到任何关于它的官方文档.

是否可以在Angular 6中实现样式加载器?

解决方法

使用Angular 7,您可以按照 this guide启用HMR. (热模块更换)

它与CSS注入不同,但它比完全重载和安装快得多.编译.

最棒的是它也适用于你的ts文件.

小附录:

我认为你可以通过注入加载改变的CSS但是遵循HMR documentation的这一部分

版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 [email protected] 举报,一经查实,本站将立刻删除。

相关推荐