Skip to content

fix: 修复 mini-css-extract-plugin 的 hmr 不生效的问题 #1602

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

chenhuang444
Copy link

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant