Conversation
Walkthrough在 getDefaultPostcssConfig 中,postcss-url 插件的配置由固定 defaultUrlOption 改为与用户提供的 options.url 合并:{ ...defaultUrlOption, ...(options?.url || {}) }。其余插件与顺序保持不变;未改动导出/公开接口。 Changes
Sequence Diagram(s)sequenceDiagram
participant Caller as Runner / 调用方
participant Config as getDefaultPostcssConfig
participant Url as postcss-url 插件
Caller->>Config: 请求 PostCSS 配置 (options)
Config->>Config: 计算 urlOpts = { ...defaultUrlOption, ...(options?.url || {}) }
Config->>Url: 以 urlOpts 实例化 postcss-url
Config-->>Caller: 返回包含各插件的数组(顺序未变)
note right of Config: 若未提供 options.url 则使用默认值
Estimated code review effort🎯 2 (Simple) | ⏱️ ~10 minutes Pre-merge checks (5 passed)✅ Passed checks (5 passed)
Poem
Tip 👮 Agentic pre-merge checks are now available in preview!Pro plan users can now enable pre-merge checks in their settings to enforce checklists before merging PRs.
Please see the documentation for more information. Example: reviews:
pre_merge_checks:
custom_checks:
- name: "Undocumented Breaking Changes"
mode: "warning"
instructions: |
Pass/fail criteria: All breaking changes to public APIs, CLI flags, environment variables, configuration keys, database schemas, or HTTP/GraphQL endpoints must be documented in the "Breaking Change" section of the PR description and in CHANGELOG.md. Exclude purely internal or private changes (e.g., code not exported from package entry points or explicitly marked as internal).Please share your feedback with us on this Discord post. 📜 Recent review detailsConfiguration used: CodeRabbit UI Review profile: CHILL Plan: Pro 📒 Files selected for processing (1)
🚧 Files skipped from review as they are similar to previous changes (1)
⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (4)
✨ Finishing Touches
🧪 Generate 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. Comment |
There was a problem hiding this comment.
Actionable comments posted: 0
🧹 Nitpick comments (1)
packages/taro-webpack5-runner/src/postcss/postcss.mini.ts (1)
48-71: 合并 url 配置方向正确,但建议兼容布尔禁用并使用深合并;同时从 options 中剔除 url 以避免无效遍历
- 兼容写法:若用户将
postcssOption.url配置为布尔值(例如false),当前实现会因options?.url || {}将其当作 falsy 而忽略,导致无法关闭插件。建议将布尔值映射为{ enable: <bool> }。- 合并方式:与上面的
autoprefixer/pxtransform/htmltransform保持一致,使用recursiveMerge做深合并,避免未来默认config字段被浅合并覆盖。- 细节优化:
...Object.entries(options)会带上url,但在getPostcssPlugins中会被过滤(['cssModules','url']),徒增一次遍历。建议构造restOptions剔除后再展开。可参考如下 diff:
- const { autoprefixer, pxtransform, htmltransform, ...options } = postcssOption + const { autoprefixer, pxtransform, htmltransform, url: urlOpt, ...restOptions } = postcssOption @@ - return [ + // 与其他插件保持一致,深合并并兼容布尔禁用 + const urlOption = recursiveMerge( + {}, + defaultUrlOption, + typeof urlOpt === 'boolean' ? { enable: urlOpt } : (urlOpt || {}) + ) + + return [ @@ - ['postcss-url', { ...defaultUrlOption, ...(options?.url || {}) }, require('postcss-url')], + ['postcss-url', urlOption, require('postcss-url')], @@ - ...Object.entries(options) + ...Object.entries(restOptions)
📜 Review details
Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro
📒 Files selected for processing (1)
packages/taro-webpack5-runner/src/postcss/postcss.mini.ts(1 hunks)
⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (6)
- GitHub Check: Build Rust Binding / stable - aarch64-apple-darwin
- GitHub Check: Build Rust Binding / stable - x86_64-unknown-linux-musl
- GitHub Check: Build Rust Binding / stable - x86_64-apple-darwin
- GitHub Check: Build Rust Binding / stable - x86_64-unknown-linux-gnu
- GitHub Check: Build Rust WASM / stable - wasm32-wasi
- GitHub Check: Build Rust Binding / stable - x86_64-pc-windows-msvc
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## main #18306 +/- ##
==========================================
- Coverage 55.06% 55.05% -0.01%
==========================================
Files 416 416
Lines 21564 21560 -4
Branches 5282 5242 -40
==========================================
- Hits 11874 11870 -4
- Misses 8032 8034 +2
+ Partials 1658 1656 -2
Flags with carried forward coverage won't be shown. Click here to find out more. 🚀 New features to boost your workflow:
|
7b61596 to
16b62b1
Compare
这个 PR 做了什么? (简要描述所做更改)
修复postcss-url 无法传递参数,出现 postcss-url: Image type is svg and link contains #. Postcss-url cant handle svg fragments. SVG file fully inlined 中warning 时,无法通过postcss url 提供的参数关闭
这个 PR 是什么类型? (至少选择一个)
这个 PR 涉及以下平台:
Summary by CodeRabbit