GeezerVison is showing github.com — feat(css): offer dropping a declaration a later one overrides by alexander-akait · Pull Request #21683 · webpack/webpack
Conversation
alexander-akait
commented
Aug 11, 2026
•
edited by coderabbitai
Bot
Loading
Uh oh!
There was an error while loading. Please reload this page.
Summary
The minifier drops an earlier declaration only when a later one in the same block is spelled identically, because a differently-spelled pair is usually a fallback — dropping it is how other minifiers lose a color(display-p3 …). csso and cssnano expose the wider drop; webpack had no way to ask for it. Adds optimization.minimize.css.dropOverriddenDeclarations, off by default, widening the match to any earlier declaration of the same property.
An earlier !important declaration is kept for a later plain one, which does not override it. Forwarded to the CSS minifier the HTML minifier nests, so an inline <style> is held to the same rules as a .css asset.
What kind of change does this PR introduce?
feat — one new opt-in option; nothing changes unless it is set.
Did you add tests for your changes?
Yes — test/configCases/css/minimize-drop-overridden snapshots all five cases: the plain override drops, the fallback pair drops (what the option opts into), color: red !important; color: blue keeps both, two !important declarations still collapse, and a nested rule parts the declarations around it. The 503 existing css/html snapshots pass unchanged, which is the evidence the default is untouched.
Does this PR introduce a breaking change?
No — off by default.
If relevant, what needs to be documented once your changes are merged or what have you already documented?
One new optimization.minimize.css property; its description in schemas/WebpackOptions.json states the fallback trade-off and the !important rule.
Use of AI
AI (Claude Code) was used to widen the existing supersede pass behind the option, thread it through the schema → cssMinify/htmlMinify → SourceProcessor → printer path, and write the test. All output was reviewed and the lint, type, generator and test checks were run locally.
Generated by Claude Code
Summary by CodeRabbit
- New Features
- Added an optional CSS minimization setting to remove declarations overridden later in the same rule.
- Preserves earlier
!important declarations unless a later !important declaration supersedes them.
- Applies to CSS files, inline styles, and embedded
<style> content.
- The setting is disabled by default.
Sorry, something went wrong.
Uh oh!
There was an error while loading. Please reload this page.
The minifier drops an earlier declaration only when a later one in the block is
spelled identically — a differently-spelled pair is a fallback, and dropping it
is how other minifiers lose a `color(display-p3 …)`. csso and cssnano expose
the wider drop; webpack had no way to ask for it.
Add `optimization.minimize.css.dropOverriddenDeclarations`, off by default,
which widens the match to any earlier declaration of the same property. An
earlier `!important` declaration is kept for a later plain one, which does not
override it. Forwarded to the CSS minifier the HTML minifier nests, so an
inline sheet is held to the same rules as a `.css` asset.
Sorry, something went wrong.
Uh oh!
There was an error while loading. Please reload this page.
coderabbitai
Bot
commented
Aug 11, 2026
•
edited
Loading
Uh oh!
There was an error while loading. Please reload this page.
|

Note
.coderabbit.yaml has unrecognized properties
CodeRabbit is using all valid settings from your configuration. Unrecognized properties (listed below) have been ignored and may indicate typos or deprecated fields that can be removed.
⚠️ Parsing warnings (1)
Validation error: Unrecognized key: "tools"
⚙️ Configuration instructions
- Please see the configuration documentation for more information.
- You can also validate your configuration using the online YAML validator.
- If your editor has YAML language server enabled, you can add the path at the top of this file to enable auto-completion and validation:
# yaml-language-server: $schema=https://coderabbit.ai/integrations/schema.v2.json
📝 Walkthrough
Walkthrough
Overview
Adds the opt-in dropOverriddenDeclarations CSS minimization option. The option applies to CSS and inline HTML styles, removes superseded declarations, preserves !important precedence, and is covered by a configuration test.
Changes
CSS declaration minimization
| Layer / File(s) |
Summary |
CSS processing and option plumbing lib/css/cssMinify.js, lib/css/syntax.js, lib/util/SourceProcessor.js |
The option flows through SourceProcessor into CSS printing. Enabled processing removes earlier declarations overridden by later declarations. |
HTML inline CSS propagation lib/html/htmlMinify.js, lib/html/syntax.js |
HTML processing forwards the option to inline <style> content and style attributes. |
Configuration and integration validation schemas/WebpackOptions.json, test/configCases/css/minimize-drop-overridden/*, .changeset/048-css-drop-overridden-declarations.md |
The schema defines the boolean option with a disabled default. The configuration test checks overridden declarations, fallback pairs, nested rules, and !important precedence. Release metadata documents the new option. |
Possibly related PRs
Suggested reviewers: bjohansebas
🚥 Pre-merge checks | ✅ 3 | ❌ 1
❌ Failed checks (1 inconclusive)
| Check name |
Status |
Explanation |
Resolution |
| Title check |
❓ Inconclusive |
The title uses valid conventional-commit syntax and describes the CSS option, but the branch prefix is not provided, so type alignment cannot be verified. |
Provide the branch name or branch prefix to verify that the feat type matches it. |
✅ Passed checks (3 passed)
| Check name |
Status |
Explanation |
| Description Check |
✅ Passed |
Check skipped - CodeRabbit’s high-level summary is enabled. |
| 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. |
Warning Tools execution failed with the following error:
Failed to run tools: 14 UNAVAILABLE: read ECONNRESET
Comment @coderabbitai help to get the list of available commands.
|
Sorry, something went wrong.
Uh oh!
There was an error while loading. Please reload this page.
|
This PR is packaged and the instant preview is available (1147bbd).
Install it locally:
npm i -D webpack@https://pkg.pr.new/webpack@1147bbd
yarn add -D webpack@https://pkg.pr.new/webpack@1147bbd
pnpm add -D webpack@https://pkg.pr.new/webpack@1147bbd
|
Sorry, something went wrong.
Uh oh!
There was an error while loading. Please reload this page.
Types CoverageCoverage after merging feat/css-minimizer-drop-overridden into main will be
Coverage Report| File | Stmts | Branches | Funcs | Lines | Uncovered Lines |
|---|
| bin | | webpack.js | 98.82% | 100% | 100% | 98.82% | 103 | | examples | | build-common.js | 100% | 100% | 100% | 100% | | | buildAll.js | 100% | 100% | 100% | 100% | | | examples.js | 100% | 100% | 100% | 100% | | | template-common.js | 98.21% | 100% | 100% | 98.21% | 72 | | examples/custom-javascript-parser | | test.filter.js | 100% | 100% | 100% | 100% | | | examples/custom-javascript-parser/internals | | acorn-parse.js | 100% | 100% | 100% | 100% | | | meriyah-parse.js | 100% | 100% | 100% | 100% | | | oxc-parse.js | 100% | 100% | 100% | 100% | | | examples/markdown | | webpack.config.mjs | 100% | 100% | 100% | 100% | | | examples/module-federation | | test.filter.js | 100% | 100% | 100% | 100% | | | examples/reexport-components | | test.filter.js | 100% | 100% | 100% | 100% | | | examples/typescript | | test.filter.js | 100% | 100% | 100% | 100% | | | examples/typescript-non-erasable | | test.filter.js | 50% | 100% | 100% | 50% | 5 | | examples/virtual-modules | | test.filter.js | 100% | 100% | 100% | 100% | | | examples/wasm-bindgen-esm | | test.filter.js | 100% | 100% | 100% | 100% | | | examples/wasm-complex | | test.filter.js | 100% | 100% | 100% | 100% | | | examples/wasm-emscripten | | test.filter.js | 100% | 100% | 100% | 100% | | | examples/wasm-simple | | test.filter.js | 100% | 100% | 100% | 100% | | | examples/wasm-simple-source-phase | | test.filter.js | 100% | 100% | 100% | 100% | | | lib | | APIPlugin.js | 100% | 100% | 100% | 100% | | | AsyncDependenciesBlock.js | 100% | 100% | 100% | 100% | | | AutomaticPrefetchPlugin.js | 100% | 100% | 100% | 100% | | | BannerPlugin.js | 100% | 100% | 100% | 100% | | | Cache.js | 98.21% | 100% | 100% | 98.21% | 101 | | CacheFacade.js | 100% | 100% | 100% | 100% | | | Chunk.js | 99.72% | 100% | 100% | 99.72% | 39 | | ChunkGraph.js | 100% | 100% | 100% | 100% | | | ChunkGroup.js | 100% | 100% | 100% | 100% | | | ChunkTemplate.js | 100% | 100% | 100% | 100% | | | CircularModulesPlugin.js | 98.81% | 100% | 100% | 98.81% | 136 | | CleanPlugin.js | 99.12% | 100% | 100% | 99.12% | 214, 234 | | CodeGenerationResults.js | 100% | 100% | 100% | 100% | | | CompatibilityPlugin.js | 100% | 100% | 100% | 100% | | | Compilation.js | 98.44% | 100% | 100% | 98.44% | 1673, 1992, 1999, 2007, 2029, 2032, 2971, 3450–3451, 3483, 4192, 4222, 4275–4276, 4280, 4285, 4301–4302, 4316–4317, 4322–4323, 4843, 4869, 549, 554, 5679, 5711, 5728, 5746, 5762, 5777, 5802–5803, 5805, 6140, 6145, 6151, 6154, 6161, 6173, 6175, 6179, 6197, 6212, 6246, 6302, 6326, 6442, 801–802 | | Compiler.js | 99.56% | 100% | 100% | 99.56% | 1168–1169, 1177 | | ConcatenationScope.js | 99.12% | 100% | 100% | 99.12% | 300 | | ConditionalInitFragment.js | 100% | 100% | 100% | 100% | | | ConstPlugin.js | 100% | 100% | 100% | 100% | | | ContextExclusionPlugin.js | 100% | 100% | 100% | 100% | | | ContextModule.js | 99.88% | 100% | 100% | 99.88% | 1461 | | ContextModuleFactory.js | 97.20% | 100% | 100% | 97.20% | 266, 435, 456, 461, 501, 512, 514, 518, 527–528 | | ContextReplacementPlugin.js | 100% | 100% | 100% | 100% | | | DefinePlugin.js | 99.08% | 100% | 100% | 99.08% | 1080, 176–177, 193, 212, 286 | | DependenciesBlock.js | 100% | 100% | 100% | 100% | | | Dependency.js | 98.51% | 100% | 100% | 98.51% | 480, 527 | | DependencyTemplate.js | 100% | 100% | 100% | 100% | | | DependencyTemplates.js | 100% | 100% | 100% | 100% | | | DotenvPlugin.js | 98.41% | 100% | 100% | 98.41% | 378, 391–392 | | DynamicEntryPlugin.js | 100% | 100% | 100% | 100% | | | EntryOptionPlugin.js | 100% | 100% | 100% | 100% | | | EntryPlugin.js | 100% | 100% | 100% | 100% | | | Entrypoint.js | 100% | 100% | 100% | 100% | | | EnvironmentPlugin.js | 97.14% | 100% | 100% | 97.14% | 49 | | ErrorHelpers.js | 100% | 100% | 100% | 100% | | | EvalDevToolModulePlugin.js | 100% | 100% | 100% | 100% | | | EvalSourceMapDevToolPlugin.js | 100% | 100% | 100% | 100% | | | ExportsInfo.js | 100% | 100% | 100% | 100% | | | ExportsInfoApiPlugin.js | 100% | 100% | 100% | 100% | | | ExternalModule.js | 98.67% | 100% | 100% | 98.67% | 1220, 1223, 519–523, 525, 671 | | ExternalModuleFactoryPlugin.js | 100% | 100% | 100% | 100% | | | ExternalsPlugin.js | 100% | 100% | 100% | 100% | | | FileSystemInfo.js | 99.53% | 100% | 100% | 99.53% | 186, 2454–2455, 2458, 2469, 2480, 2491, 284, 3928, 3943, 3967 | | FlagAllModulesAsUsedPlugin.js | 100% | 100% | 100% | 100% | | | FlagDependencyExportsPlugin.js | 98.36% | 100% | 100% | 98.36% | 504, 513, 516, 520, 532 | | FlagDependencyUsagePlugin.js | 100% | 100% | 100% | 100% | | | FlagEntryExportAsUsedPlugin.js | 100% | 100% | 100% | 100% | | | Generator.js | 100% | 100% | 100% | 100% | | | HotModuleReplacementPlugin.js | 100% | 100% | 100% | 100% | | | HotUpdateChunk.js | 100% | 100% | 100% | 100% | | | IgnorePlugin.js | 100% | 100% | 100% | 100% | | | IgnoreWarningsPlugin.js | 100% | 100% | 100% | 100% | | | InitFragment.js | 100% | 100% | 100% | 100% | | | JavascriptMetaInfoPlugin.js | 100% | 100% | 100% | 100% | | | LazyBarrel.js | 100% | 100% | 100% | 100% | | | LibraryTemplatePlugin.js | 100% | 100% | 100% | 100% | | | LoaderOptionsPlugin.js | 100% | 100% | 100% | 100% | | | LoaderTargetPlugin.js | 100% | 100% | 100% | 100% | | | MainTemplate.js | 100% | 100% | 100% | 100% | | | ManifestPlugin.js | 100% | 100% | 100% | 100% | | | Module.js | 98.51% | 100% | 100% | 98.51% | 1303, 1308, 1368, 1382, 1444, 1453 | | ModuleFactory.js | 100% | 100% | 100% | 100% | | | ModuleFilenameHelpers.js | 98.90% | 100% | 100% | 98.90% | 111, 113 | | ModuleGraph.js | 99.78% | 100% | 100% | 99.78% | 1170 | | ModuleGraphConnection.js | 100% | 100% | 100% | 100% | | | ModuleInfoHeaderPlugin.js | 100% | 100% | 100% | 100% | | | ModuleNotFoundError.js | 100% | 100% | 100% | 100% | | | ModuleProfile.js | 100% | 100% | 100% | 100% | | | ModuleSourceTypeConstants.js | 100% | 100% | 100% | 100% | | | ModuleTemplate.js | 100% | 100% | 100% | 100% | | | ModuleTypeConstants.js | 100% | 100% | 100% | 100% | | | MultiCompiler.js | 99.72% | 100% | 100% | 99.72% | 721 | | MultiStats.js | 100% | 100% | 100% | 100% | | | MultiWatching.js | 100% | 100% | 100% | 100% | | | NoEmitOnErrorsPlugin.js | 100% | 100% | 100% | 100% | | | NodeStuffPlugin.js | 100% | 100% | 100% | 100% | | | NormalModule.js | 97.99% | 100% | 100% | 97.99% | 1027, 1030, 1047, 1064, 1312, 1346, 1362, 1817, 2114, 2119–2129, 29 | | NormalModuleFactory.js | 98.77% | 100% | 100% | 98.77% | 1142, 1410, 1421, 1431, 1482–1484, 1491, 536, 548 | | NormalModuleReplacementPlugin.js | 100% | 100% | 100% | 100% | | | NullFactory.js | 100% | 100% | 100% | 100% | | | OptimizationStages.js | 100% | 100% | 100% | 100% | | | OptionsApply.js | 100% | 100% | 100% | 100% | | | Parser.js | 100% | 100% | 100% | 100% | | | PlatformPlugin.js | 100% | 100% | 100% | 100% | | | PrefetchPlugin.js | 100% | 100% | 100% | 100% | | | ProgressPlugin.js | 99.80% | 100% | 100% | 99.80% | 690 | | ProvidePlugin.js | 100% | 100% | 100% | 100% | | | RawModule.js | 100% | 100% | 100% | 100% | | | RecordIdsPlugin.js | 100% | 100% | 100% | 100% | | | RequestShortener.js | 100% | 100% | 100% | 100% | | | ResolverFactory.js | 100% | 100% | 100% | 100% | | | RuntimeGlobals.js | 100% | 100% | 100% | 100% | | | RuntimeModule.js | 100% | 100% | 100% | 100% | | | RuntimePlugin.js | 95.69% | 100% | 100% | 95.69% | 310, 366, 375, 378, 402, 420, 441–442, 465, 485–486, 522–523, 546, 559–560, 632, 645, 666, 685 | | RuntimeTemplate.js | 99.91% | 100% | 100% | 99.91% | 123 | | SelfModuleFactory.js | 100% | 100% | 100% | 100% | | | SingleEntryPlugin.js | 100% | 100% | 100% | 100% | | | SourceMapDevToolModuleOptionsPlugin.js | 100% | 100% | 100% | 100% | | | SourceMapDevToolPlugin.js | 98.63% | 100% | 100% | 98.63% | 220, 224, 226, 420, 431, 890 | | Stats.js | 100% | 100% | 100% | 100% | | | Template.js | 100% | 100% | 100% | 100% | | | TemplatedPathPlugin.js | 99.48% | 100% | 100% | 99.48% | 364–365 | | UseStrictPlugin.js | 100% | 100% | 100% | 100% | | | WarnCaseSensitiveModulesPlugin.js | 100% | 100% | 100% | 100% | | | WarnDeprecatedOptionPlugin.js | 100% | 100% | 100% | 100% | | | WarnNoModeSetPlugin.js | 100% | 100% | 100% | 100% | | | WatchIgnorePlugin.js | 100% | 100% | 100% | 100% | | | Watching.js | 100% | 100% | 100% | 100% | | | WebpackError.js | 100% | 100% | 100% | 100% | | | WebpackIsIncludedPlugin.js | 100% | 100% | 100% | 100% | | | WebpackOptionsApply.js | 100% | 100% | 100% | 100% | | | WebpackOptionsDefaulter.js | 100% | 100% | 100% | 100% | | | buildChunkGraph.js | 99.87% | 100% | 100% | 99.87% | 376 | | cli.js | 98.63% | 100% | 100% | 98.63% | 10, 119, 549, 581, 631, 905 | | index.js | 99.73% | 100% | 100% | 99.73% | 184 | | validateSchema.js | 94.67% | 100% | 100% | 94.67% | 100, 87, 89, 98 | | webpack.js | 97.12% | 100% | 100% | 97.12% | 10, 267, 289, 291 | | lib/asset | | AssetBytesGenerator.js | 100% | 100% | 100% | 100% | | | AssetBytesParser.js | 100% | 100% | 100% | 100% | | | AssetGenerator.js | 100% | 100% | 100% | 100% | | | AssetModule.js | 100% | 100% | 100% | 100% | | | AssetModulesPlugin.js | 98.15% | 100% | 100% | 98.15% | 330, 354, 357, 487, 49, 54 | | AssetParser.js | 100% | 100% | 100% | 100% | | | AssetSourceGenerator.js | 100% | 100% | 100% | 100% | | | AssetSourceParser.js | 100% | 100% | 100% | 100% | | | RawDataUrlModule.js | 100% | 100% | 100% | 100% | | | WebManifestGenerator.js | 100% | 100% | 100% | 100% | | | WebManifestParser.js | 100% | 100% | 100% | 100% | | | lib/async-modules | | AsyncModuleHelpers.js | 100% | 100% | 100% | 100% | | | AwaitDependenciesInitFragment.js | 100% | 100% | 100% | 100% | | | InferAsyncModulesPlugin.js | 100% | 100% | 100% | 100% | | | isGeneratorLowered.js | 100% | 100% | 100% | 100% | | | lib/bun | | BunTargetPlugin.js | 100% | 100% | 100% | 100% | | | lib/cache | | AddBuildDependenciesPlugin.js | 100% | 100% | 100% | 100% | | | AddManagedPathsPlugin.js | 100% | 100% | 100% | 100% | | | IdleFileCachePlugin.js | 97.92% | 100% | 100% | 97.92% | 75, 87, 95 | | MemoryCachePlugin.js | 92% | 100% | 100% | 92% | 34, 43 | | MemoryWithGcCachePlugin.js | 93.42% | 100% | 100% | 93.42% | 108, 122–123, 132, 90 | | PackFileCacheStrategy.js | 96.52% | 100% | 100% | 96.52% | 1310, 1410, 1414, 1476, 1712, 1796, 1819, 1851, 675, 694, 704–706, 708, 724–725, 730, 733, 735, 740, 745, 770, 776, 810, |
|
Sorry, something went wrong.
Uh oh!
There was an error while loading. Please reload this page.
codecov
Bot
commented
Aug 11, 2026
•
edited
Loading
Uh oh!
There was an error while loading. Please reload this page.
|
❌ Patch coverage is 82.35294% with 3 lines in your changes missing coverage. Please review.
✅ Project coverage is 94.53%. Comparing base (638ce71) to head (1147bbd).
Additional details and impacted files
@@ Coverage Diff @@
## main #21683 +/- ##
==========================================
- Coverage 94.53% 94.53% -0.01%
==========================================
Files 631 631
Lines 82362 82376 +14
Branches 24405 24412 +7
==========================================
+ Hits 77861 77872 +11
- Misses 4501 4504 +3
Flags with carried forward coverage won't be shown. Click here to find out more.
☔ View full report in Codecov by Harness.
📢 Have feedback on the report? Share it here.
🚀 New features to boost your workflow:
- ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
- 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.
|
Sorry, something went wrong.
Uh oh!
There was an error while loading. Please reload this page.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Actionable comments posted: 3
🧹 Nitpick comments (1)
lib/html/htmlMinify.js (1)
63-65: 📐 Maintainability & Code Quality | 🔵 Trivial | ⚡ Quick win
Shorten the added comment.
The comment uses three long lines. Reduce it to at most two short lines.
As per coding guidelines: “Keep comments as short as possible, generally one line and no more than two short lines.”
🤖 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 `@lib/html/htmlMinify.js` around lines 63 - 65, Shorten the comment above the
minification process to no more than two concise lines, preserving only the
essential details about single-pass parsing, minified serialization, and unused
source-map mappings.
Source: Coding guidelines
🤖 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 `@lib/css/syntax.js`:
- Around line 9175-9189: In the declaration-processing loop around
_dropOverriddenDeclarations, skip any item whose texts[i].length is zero before
reading or updating seen, so empty non-custom declarations cannot supersede
valid declarations. Add a regression test for `.a { color: red; color: }` that
preserves the emitted red declaration.
- Around line 9178-9189: Update the declaration tracking around seen and
superseded so a plain declaration cannot replace the effective earlier
!important index; retain separate normal and important indices or equivalent
precedence-aware tracking, ensuring
color:red!important;color:blue;color:green!important supersedes only color:blue
while retaining the first important declaration. Add this sequence to the
existing regression test.
- Around line 9175-9177: Update the supersession key construction around
_dropOverriddenDeclarations so names beginning with -- bypass
toLowerCaseIfNeeded and retain their original case, while ordinary properties
keep the existing normalization. Add a regression case covering two custom
properties that differ only by case and ensure both remain available for
matching var() references.
---
Nitpick comments:
In `@lib/html/htmlMinify.js`:
- Around line 63-65: Shorten the comment above the minification process to no
more than two concise lines, preserving only the essential details about
single-pass parsing, minified serialization, and unused source-map mappings.
🪄 Autofix
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: Path: .coderabbit.yaml
Review profile: CHILL
Plan: Pro Plus
Run ID: c627a643-f343-4737-90a4-d0ff84000f7a
📥 Commits
Reviewing files that changed from the base of the PR and between 638ce71 and 1147bbd.
⛔ Files ignored due to path filters (6)
declarations/WebpackOptions.d.ts is excluded by !declarations/**
schemas/WebpackOptions.check.js is excluded by !schemas/**/*.check.js
test/__snapshots__/Cli.basictest.js.snap is excluded by !**/*.snap, !test/**/__snapshots__/**
test/configCases/css/minimize-drop-overridden/__snapshots__/ConfigCacheTest.snap is excluded by !**/*.snap, !test/**/__snapshots__/**
test/configCases/css/minimize-drop-overridden/__snapshots__/ConfigTest.snap is excluded by !**/*.snap, !test/**/__snapshots__/**
types.d.ts is excluded by !types.d.ts
📒 Files selected for processing (11)
.changeset/048-css-drop-overridden-declarations.md
lib/css/cssMinify.js
lib/css/syntax.js
lib/html/htmlMinify.js
lib/html/syntax.js
lib/util/SourceProcessor.js
schemas/WebpackOptions.json
test/configCases/css/minimize-drop-overridden/index.js
test/configCases/css/minimize-drop-overridden/style.css
test/configCases/css/minimize-drop-overridden/test.config.js
test/configCases/css/minimize-drop-overridden/webpack.config.js
🔗 Linked repositories identified
CodeRabbit considers these linked repositories for cross-repo context during reviews:
webpack/schema-utils (auto-detected)
webpack/tapable (auto-detected)
Sorry, something went wrong.
Uh oh!
There was an error while loading. Please reload this page.
Comment on lines
+9175
to
+9177
|
|
const key = _dropOverriddenDeclarations
|
|
|
? toLowerCaseIfNeeded(path.name(items[i]))
|
|
|
: texts[i];
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
🎯 Functional Correctness | 🟠 Major | ⚡ Quick win
Preserve custom property name case.
Custom property names are case-sensitive. This key lowercases --Theme and --theme, so the option drops one even though they are distinct properties. A later var(--Theme) can then become invalid.
Keep names that start with -- unchanged when building the supersession key. Add a regression case with two custom properties that differ only by case.
🤖 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 `@lib/css/syntax.js` around lines 9175 - 9177, Update the supersession key
construction around _dropOverriddenDeclarations so names beginning with --
bypass toLowerCaseIfNeeded and retain their original case, while ordinary
properties keep the existing normalization. Add a regression case covering two
custom properties that differ only by case and ensure both remain available for
matching var() references.
Sorry, something went wrong.
Uh oh!
There was an error while loading. Please reload this page.
Comment on lines
+9175
to
+9189
|
|
const key = _dropOverriddenDeclarations
|
|
|
? toLowerCaseIfNeeded(path.name(items[i]))
|
|
|
: texts[i];
|
|
|
const at = seen.get(key);
|
|
|
// A later plain declaration does not override an earlier
|
|
|
// `!important` one, so that one is still read and stays.
|
|
|
if (
|
|
|
at !== undefined &&
|
|
|
(!_dropOverriddenDeclarations ||
|
|
|
!path.important(items[at]) ||
|
|
|
path.important(items[i]))
|
|
|
) {
|
|
|
superseded.add(at);
|
|
|
}
|
|
|
seen.set(key, i);
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
🎯 Functional Correctness | 🟠 Major | ⚡ Quick win
Skip declarations that emit no text.
A value-less non-custom declaration emits "" at Line 8992, but this loop still records it as an override. With .a { color: red; color: }, the invalid second declaration marks color: red as superseded, then emits nothing. The output loses the valid declaration.
Skip items where texts[i].length === 0 before reading or updating seen. Add this regression case.
🤖 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 `@lib/css/syntax.js` around lines 9175 - 9189, In the declaration-processing
loop around _dropOverriddenDeclarations, skip any item whose texts[i].length is
zero before reading or updating seen, so empty non-custom declarations cannot
supersede valid declarations. Add a regression test for `.a { color: red; color:
}` that preserves the emitted red declaration.
Sorry, something went wrong.
Uh oh!
There was an error while loading. Please reload this page.
Comment on lines
+9178
to
+9189
|
|
const at = seen.get(key);
|
|
|
// A later plain declaration does not override an earlier
|
|
|
// `!important` one, so that one is still read and stays.
|
|
|
if (
|
|
|
at !== undefined &&
|
|
|
(!_dropOverriddenDeclarations ||
|
|
|
!path.important(items[at]) ||
|
|
|
path.important(items[i]))
|
|
|
) {
|
|
|
superseded.add(at);
|
|
|
}
|
|
|
seen.set(key, i);
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
🎯 Functional Correctness | 🟡 Minor | ⚡ Quick win
Retain the effective !important declaration index.
A plain declaration replaces the seen index even when it cannot override an earlier !important declaration. For color:red!important;color:blue;color:green!important, the final declaration only supersedes color:blue; it leaves the first important declaration.
Track normal and important declarations separately, or scan in reverse by cascade precedence. Add this sequence to the regression test.
🤖 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 `@lib/css/syntax.js` around lines 9178 - 9189, Update the declaration tracking
around seen and superseded so a plain declaration cannot replace the effective
earlier !important index; retain separate normal and important indices or
equivalent precedence-aware tracking, ensuring
color:red!important;color:blue;color:green!important supersedes only color:blue
while retaining the first important declaration. Add this sequence to the
existing regression test.
Sorry, something went wrong.
Uh oh!
There was an error while loading. Please reload this page.
Generated code size
Comparing 1147bbd merged into 638ce71 against 638ce71. Merging this PR will change the code webpack generates.
|
Changed |
New |
Deleted |
Unchanged |
Raw change |
| Cases |
2 |
1 |
0 |
1569 |
🔴 ↑ +261 B |
| Assets |
2 |
2 |
0 |
6155 |
🔴 ↑ +261 B |
| Runtimes |
0 |
1 |
0 |
1933 |
— |
4 asset(s) changed size
|
Asset |
Before |
After |
Change |
Gzip (9) |
Brotli (11) |
Zstd (19) |
| ➕ |
css/minimize-drop-overridden bundle0.css |
— |
147 B |
+147 B (new) |
new |
new |
new |
| ➕ |
css/minimize-drop-overridden bundle0.js |
— |
114 B |
+114 B (new) |
new |
new |
new |
| 🟢 ↓ |
externals/externals-array 0/bundle0.js |
414 B |
414 B |
0 B (—) |
-0.34% |
— |
— |
| 🟢 ↓ |
externals/node-require bundle0.js |
502 B |
502 B |
0 B (—) |
— |
— |
-0.29% |
1 runtime(s) changed which runtime modules they carry
|
Runtime |
Modules |
Added |
Removed |
| ➕ |
css/minimize-drop-overridden main |
0 → 1 |
css loading |
— |
Built test/configCases with the defaults a user gets: 1572 case(s), 6159 asset(s), 40 emitted nothing.
|
Sorry, something went wrong.
Uh oh!
There was an error while loading. Please reload this page.
Merging this PR will regress 1 benchmark
⚠️ Different runtime environments detected
Some benchmarks with significant performance changes were compared across different runtime environments,
which may affect the accuracy of the results.
Open the report in CodSpeed to investigate
⚡ 2 improved benchmarks
❌ 1 regressed benchmark
✅ 307 untouched benchmarks
Performance Changes
Tip Investigate this regression by commenting @codspeedbot fix this regression on this PR, or directly use the CodSpeed MCP with your agent.
Comparing feat/css-minimizer-drop-overridden (1147bbd) with main (4410afe)1
Footnotes
-
No successful run was found on main (638ce71) during the generation of this report, so 4410afe was used instead as the comparison base. There might be some changes unrelated to this pull request in this report. ↩
|
Sorry, something went wrong.
Uh oh!
There was an error while loading. Please reload this page.
Unable to generate the flame graphs
The performance report has correctly been generated, but there was an internal error while generating the flame graphs for this run. We're working on fixing the issue. Feel free to contact us on Discord or at [email protected] if the issue persists.
|
Sorry, something went wrong.
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
Assignees
No one assigned
Labels
area: config
Options, defaults, validation (lib/config, schemas/)
area: css
CSS support (lib/css)
area: html
Experimental HTML support (lib/html)
area: types
types.d.ts, JSDoc annotations, hand-maintained declarations
Milestone
No milestone
Development
Successfully merging this pull request may close these issues.
Uh oh!
There was an error while loading. Please reload this page.
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.
|