Skip to content

fix: 解决taro版本demo变量文件重复注入导致超时的问题#3484

Merged
xiaoyatong merged 2 commits into
jdf2e:feat_v3.xfrom
irisSong:feat_taro_demo_optimize_3
Jun 12, 2026
Merged

fix: 解决taro版本demo变量文件重复注入导致超时的问题#3484
xiaoyatong merged 2 commits into
jdf2e:feat_v3.xfrom
irisSong:feat_taro_demo_optimize_3

Conversation

@irisSong

@irisSong irisSong commented Jun 12, 2026

Copy link
Copy Markdown
Collaborator

🤔 这个变动的性质是?

  • 新特性提交
  • 日常 bug 修复
  • 站点、文档改进
  • 演示代码改进
  • 组件样式/交互改进
  • TypeScript 定义更新
  • 包体积优化
  • 性能优化
  • 功能增强
  • 国际化改进
  • 重构
  • 代码风格优化
  • 测试用例
  • 分支合并
  • 其他改动(是关于什么的改动?)

🔗 相关 Issue

💡 需求背景和解决方案

☑️ 请求合并前的自查清单

⚠️ 请自检并全部勾选全部选项⚠️

  • 文档已补充或无须补充
  • 代码演示已提供或无须提供
  • TypeScript 定义已补充或无须补充
  • fork仓库代码是否为最新避免文件冲突
  • Files changed 没有 package.json lock 等无关文件

Summary by CodeRabbit

发布说明

  • Chores
    • 优化小程序样式编译,解决 WXSS 编译超时问题并降低产物体积与重复资源
    • 改进样式打包机制,将多组件样式合并为统一 bundle 以提升构建稳定性
    • 调整生成的应用配置模板以简化构建输出,并在构建流程中排除该 bundle 致 H5 按组件发包不受影响

@github-actions github-actions Bot added action:review This PR needs more reviews (less than 2 approvals) 3.x Target branch 3.x labels Jun 12, 2026
@coderabbitai

coderabbitai Bot commented Jun 12, 2026

Copy link
Copy Markdown

Review Change Stack

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Repository UI

Review profile: CHILL

Plan: Pro

Run ID: 40a1c851-c413-4f7b-9d6a-612e9fd94cf5

📥 Commits

Reviewing files that changed from the base of the PR and between 14b89d5 and 6e19b26.

📒 Files selected for processing (1)
  • scripts/build.mjs

Walkthrough

将 NutUI React 的多个 Taro 端组件 SCSS 合并为单一 bundle,生成并写入 bundle 文件;更新生成脚本与构建管道忽略规则;移除生成的 Taro app.config 模板中的无效 renderingMode 字段,并附带治理方案文档与验证步骤。

变更详情

WXSS 编译超时治理

Layer / File(s) Summary
治理方案文档与问题分析
.cursor/skills/nutui-taro-weapp-wxss/SKILL.md
记录 WXSS 超时根因(wcsc 处理体积过大、@font-face 重复)、SCSS bundle 合并方案、最小改动清单、影响矩阵、已知限制、验证命令与未采纳方案备查。
SCSS Bundle 打包入口文件
src/packages/nutui.react.scss.taro.bundle.scss
新增统一的 Taro 端组件样式入口,按顺序 import 变量、主题及各组件(按钮、布局、表单等)的 SCSS 文件。
Bundle 生成脚本与逻辑
scripts/taro/generate-nutui-taro.js
引入 bundleScssStr 累积变量,在组件循环中同步追加 SCSS import 语句,生成 bundle SCSS 文件后再由 TS 入口引用。
构建流程排除规则
scripts/build-taro.mjs, scripts/build.mjs
更新 buildCSSbuildHarmonyCSS 中的 glob 过滤,排除 nutui.react.scss.taro.bundle.scss 以防止重复处理与编译。
配置模板清理
scripts/harmony/update-taro-entry.js,
scripts/taro/generate-taro-route.js
从生成的 defineAppConfig 模板中删除无效的 renderingMode: 'mixed' 字段。

🎯 2 (Simple) | ⏱️ ~12 分钟

可能相关的 PR

  • jdf2e/nutui-react#3316: 修改了 scripts/build-taro.mjs 的 Harmony CSS 构建流程输入集合/逻辑,和本 PR 在构建输入选择上相关联。
  • jdf2e/nutui-react#2476: 同样修改了生成 Taro app.config.ts 的脚本逻辑,和本次移除 renderingMode 的改动具备代码级联系。

建议审阅者

  • xiaoyatong
  • oasis-cloud

兔兔之歌 🐰

我把样式合成一团,少了重复与纷繁,
WXSS 也能轻装上阵,编译时间不再慢斟,
renderingMode 说再见,构建管线更整齐,
小程序笑开颜,Taro 路更稳更真挚。 🥕✨

🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Description check ⚠️ Warning PR描述仅包含未填写的模板框架,缺少必要的变更说明、相关Issue、解决方案详情和自查清单的勾选。 补充PR描述:选择变更类型(包体积优化、性能优化等),详述问题背景与解决方案,勾选自查清单所有项目。
✅ Passed checks (4 passed)
Check name Status Explanation
Title check ✅ Passed 标题清晰准确地描述了主要变更:通过优化样式文件打包和移除重复配置项来解决Taro demo构建超时问题。
Docstring Coverage ✅ Passed Docstring coverage is 100.00% which is sufficient. The required threshold is 80.00%.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Actionable comments posted: 2

🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Inline comments:
In @.cursor/skills/nutui-taro-weapp-wxss/SKILL.md:
- Around line 22-23: Summary: The acceptance criteria for duplicate `@font-face`
counts are inconsistent between the table (“2–10”) and line 85 (“个位数”); make
them consistent. Fix: choose a single threshold phrasing (e.g., "<=10" or "1–9")
and update both the table row containing "`@font-face` 重复 | ~216 | ~2–10 |" and
the sentence on line 85 that currently says “个位数” so they match exactly; ensure
the chosen representation is used consistently elsewhere in the document.

In `@scripts/taro/generate-nutui-taro.js`:
- Line 10: The generated bundleScssStr currently emits `@import` with “.scss”
suffix (variable bundleScssStr in scripts/taro/generate-nutui-taro.js), which
violates the scss/load-partial-extension lint rule; update the generator to emit
imports without the “.scss” extension (e.g. "`@import` '../styles/variables';" and
"`@import` '../styles/theme-default';") and apply the same change to the other
generator occurrences noted around the file (the other bundle string
constructions). After changing the generator, regenerate and commit the produced
nutui.react.scss.taro.bundle.scss artifact so the repo no longer contains
lint-failing imports.
🪄 Autofix (Beta)

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: Repository UI

Review profile: CHILL

Plan: Pro

Run ID: d494a515-ffa0-4f8c-8188-6a3cbdb62933

📥 Commits

Reviewing files that changed from the base of the PR and between 2342988 and 14b89d5.

📒 Files selected for processing (6)
  • .cursor/skills/nutui-taro-weapp-wxss/SKILL.md
  • scripts/build-taro.mjs
  • scripts/harmony/update-taro-entry.js
  • scripts/taro/generate-nutui-taro.js
  • scripts/taro/generate-taro-route.js
  • src/packages/nutui.react.scss.taro.bundle.scss
💤 Files with no reviewable changes (2)
  • scripts/taro/generate-taro-route.js
  • scripts/harmony/update-taro-entry.js

Comment on lines +22 to +23
| `@font-face` 重复 | ~216 | ~2–10 |

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

⚠️ Potential issue | 🟡 Minor | ⚡ Quick win

验收口径需要统一(“2–10”与“个位数”冲突)。

Line 22-23 写的是修复后 @font-face2–10,但 Line 85 期望写“个位数”。建议统一成同一阈值(例如“<=10”或“1–9”),避免验证时标准不一致。

Also applies to: 85-85

🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In @.cursor/skills/nutui-taro-weapp-wxss/SKILL.md around lines 22 - 23, Summary:
The acceptance criteria for duplicate `@font-face` counts are inconsistent
between the table (“2–10”) and line 85 (“个位数”); make them consistent. Fix:
choose a single threshold phrasing (e.g., "<=10" or "1–9") and update both the
table row containing "`@font-face` 重复 | ~216 | ~2–10 |" and the sentence on line
85 that currently says “个位数” so they match exactly; ensure the chosen
representation is used consistently elsewhere in the document.

let importRNStr = ``
let importMarkdownStr = ``
let importScssStr = `\n`
let bundleScssStr = `@import '../styles/variables.scss';\n@import '../styles/theme-default.scss';\n`

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

⚠️ Potential issue | 🟠 Major | ⚡ Quick win

生成的 bundle @import 与当前 stylelint 规则不兼容,会持续产出 lint 错误。

现在脚本会生成带 .scss 后缀的 @import,与 scss/load-partial-extension 规则冲突(在产物文件中已触发整文件报错)。建议在生成阶段去掉后缀,并回刷 nutui.react.scss.taro.bundle.scss

建议修复
-let bundleScssStr = `@import '../styles/variables.scss';\n@import '../styles/theme-default.scss';\n`
+let bundleScssStr = `@import '../styles/variables';\n@import '../styles/theme-default';\n`

...
-    bundleScssStr += `@import './${name.toLowerCase()}/${name.toLowerCase()}.scss';\n`
+    bundleScssStr += `@import './${name.toLowerCase()}/${name.toLowerCase()}';\n`

Also applies to: 25-25, 115-122

🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@scripts/taro/generate-nutui-taro.js` at line 10, The generated bundleScssStr
currently emits `@import` with “.scss” suffix (variable bundleScssStr in
scripts/taro/generate-nutui-taro.js), which violates the
scss/load-partial-extension lint rule; update the generator to emit imports
without the “.scss” extension (e.g. "`@import` '../styles/variables';" and
"`@import` '../styles/theme-default';") and apply the same change to the other
generator occurrences noted around the file (the other bundle string
constructions). After changing the generator, regenerate and commit the produced
nutui.react.scss.taro.bundle.scss artifact so the repo no longer contains
lint-failing imports.

Source: Linters/SAST tools

@xiaoyatong xiaoyatong merged commit b201644 into jdf2e:feat_v3.x Jun 12, 2026
5 of 6 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

3.x Target branch 3.x action:review This PR needs more reviews (less than 2 approvals) size/L

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants