fix: 修复 mini-css-extract-plugin 的 hmr 不生效的问题 #1602
Open
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
rsbuild
默认使用mini-css-extract-plugin
处理 css,它的热更新能力是通过替换<link/>
标签实现的。目前
micro-app
为了实现 CSS 隔离,将<link/>
替换成了<style/>
。这导致mini-css-extract-plugin
的热更新能力无法生效。可以通过插入
<link disabled="true" />
的标签,既可以避免原样式的加载,也可以让mini-css-extract-plugin
的热更新能力生效同时为
with
沙箱加一下document.currentScript
mini-css-extract-plugin
会通过该字段记录module-id
->chunk href
的映射关系。hmr
的具体实现可以参考hotModuleReplacement.js
https://github.com/webpack-contrib/mini-css-extract-plugin/blob/master/src/hmr/hotModuleReplacement.js
修复:#1510