Repository navigation
feat(html): allow object for optimization.minimize to support HTML minification options - #21537
Closed
aryanraj45 wants to merge 1 commit into
Closed
aryanraj45 wants to merge 1 commit into
aryanraj45 wants to merge 1 commit into
Conversation
🦋 Changeset detectedLatest commit: 7606cb0 The changes in this PR will be included in the next version bump. This PR includes changesets to release 1 package
Not sure what this means? Click here to learn what changesets are. Click here if you're a maintainer who wants to add another changeset to this PR |
aryanraj45
force-pushed
the
feat/html-minimize-options
branch
from
July 30, 2026 21:51
48f9510 to
6d7c6f5
Compare
aryanraj45
marked this pull request as ready for review
July 30, 2026 21:51
There was a problem hiding this comment.
Cursor Bugbot has reviewed your changes using default effort and found 1 potential issue.
❌ Bugbot Autofix is OFF. To automatically fix reported issues with cloud agents, enable autofix in the Cursor dashboard.
Reviewed by Cursor Bugbot for commit f9b60f3. Configure here.
Carries what a minimizer may do beyond the transforms that always apply, starting with html.collapseWhitespace: each run of whitespace in text becomes a single space, never nothing — removing it joins two inline elements that render apart. Skipped under pre/textarea/listing and for text holding a '<', which stays on the source-passthrough path.
aryanraj45
force-pushed
the
feat/html-minimize-options
branch
from
August 7, 2026 15:05
f9b60f3 to
7606cb0
Compare
Member
Author
|
@alexander-akait optimization.minimize optimization: { minimize: { html: { collapseWhitespace: true } } }
A run of whitespace becomes a single space, never dropped — removing it would join two inline elements that render apart. Skipped under pre/textarea/listing, and for text with a < so <%= x %> isn't escaped. true/false unchanged |
This was referenced Aug 27, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.

Summary
Extends HTML minification to optionally strip quotes from attributes and collapse boolean attributes when
optimization.minimizeis configured as an options object.This builds on the safe minify groundwork introduced in #21491. While #21491 establishes the HTML/CSS minimizers, this PR updates the Webpack schema to allow
optimization.minimizeto be an object instead of just a boolean. This enables passing specific options down to the minimizers, and specifically implementsremoveAttributeQuotesandcollapseBooleanAttributesin the HTML printer (lib/html/syntax.js).What kind of change does this PR introduce?
feat
Did you add tests for your changes?
Yes, added
ConfigTestCasesforhtml minimizecovering the new schema object shape and attribute output.Does this PR introduce a breaking change?
No.
If relevant, what needs to be documented once your changes are merged or what have you already documented?
The new
optimization.minimizeobject options (removeAttributeQuotesandcollapseBooleanAttributes) should be documented.Use of AI
YES
Note
Medium Risk
Opt-in HTML output changes can affect layout if whitespace is relied on outside excluded elements; wiring is limited to production minify defaults but touches emitted
.htmlassets.Overview
optimization.minimizecan be an object (still accepts a boolean). An object turns minimization on and passes per-minimizer options beyond the always-safe transforms; the first supported knob ishtml.collapseWhitespace, typed asOptimizationMinimizeHtmlin the public declarations and JSON schema.When HTML minification runs,
lib/config/defaults.jsspreadsoptimization.minimize.htmlinto the built-in HTML minifier options (alongside the existing CSSenvironment).htmlMinifyforwardscollapseWhitespaceinto the HTMLSourceProcessor, which implements optional text-node collapsing via a newcollapseWshelper: runs of HTML whitespace become a single space, never removed entirely, skipped underpre/textarea/listingancestors, and skipped when text contains<so template-like content stays on the passthrough path.Reviewed by Cursor Bugbot for commit 7606cb0. Bugbot is set up for automated code reviews on this repo. Configure here.