Skip to content

fix: 修复输出RN时style block内单独@import css文件时报错问题#2157

Merged
hiyuki merged 5 commits intomasterfrom
fix-rn-style-css-import
Feb 3, 2026
Merged

fix: 修复输出RN时style block内单独@import css文件时报错问题#2157
hiyuki merged 5 commits intomasterfrom
fix-rn-style-css-import

Conversation

@Blackgan3
Copy link
Collaborator

修复输出RN时style block内单独@import css文件时报错问题

const printedParam = printParams(media, dedupe, supports, layer)
const otherParams = printedParam.length > 0 ? printedParam : ''
beforeCode += `___CSS_LOADER_EXPORT___.push([module.id, '@import "' + ${item.importName} + '";', ${JSON.stringify(otherParams)} ]);\n`
beforeCode += `___CSS_LOADER_EXPORT___.i(${item.importName}${printedParam.length > 0 ? `, ${printedParam}` : ''});\n`
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

为啥要改这块?

@@ -102,7 +102,8 @@ module.exports = async function loader (content, map, meta) {
return getRequestString('styles', { src: url }, {
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

这里走原始的stringifyRequest就可以了吧

if (isRN) {
beforeCode += `___CSS_LOADER_EXPORT___.i(${item.importName}${hasParams ? `, ${printedParam}` : ''});\n`
} else {
const otherParams = hasParams ? printedParam : ''
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

你这个printedParams的处理两个分支能不能拉齐一下。。。逼死强迫症

@hiyuki hiyuki merged commit de85d37 into master Feb 3, 2026
6 checks passed
@hiyuki hiyuki deleted the fix-rn-style-css-import branch February 3, 2026 13:37
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.

2 participants