fix(css): resolve cssMinify from the environment config - #23243
Open
ValentinYoushkevich wants to merge 1 commit into
Open
fix(css): resolve cssMinify from the environment config#23243ValentinYoushkevich wants to merge 1 commit into
cssMinify from the environment config#23243ValentinYoushkevich wants to merge 1 commit into
Conversation
7 tasks
`cssPostPlugin` captured the root resolved config at plugin creation and read `build.cssMinify` from it. With `builder.sharedPlugins: true` a single plugin instance is reused across environments, so a per-environment `build.cssMinify` was ignored and the root value applied everywhere. Read the option from `this.environment.config` instead, matching how the surrounding code already resolves `cssCodeSplit` and `chunkImportMap`.
ValentinYoushkevich
force-pushed
the
fix/css-minify-per-environment
branch
from
August 12, 2026 11:09
acf2f80 to
fbcb5a8
Compare
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.
Description
cssPostPlugincaptures the rootResolvedConfigat plugin creation time and readsbuild.cssMinifyfrom it. Withbuilder.sharedPlugins: truea single plugin instance is reused across every environment, so a per-environmentbuild.cssMinifywas ignored and the root value was applied everywhere — the config in #20789 produces minified CSS for both the client and the ssr build.This reads the option from
this.environment.configinstead, which is what the surrounding code in the same plugin already does forbuild.cssCodeSplit,build.emitAssetsandbuild.chunkImportMap.compileLightningCSSresolves it per environment too, so this only aligns the remaining call sites.Changed call sites, all in
cssPostPlugin:?inlinebranch intransformfinalizeCssfor__VITE_CSS_URL__emit tasksfinalizeCssfor code-split chunk CSSfinalizeCssfor inlined chunk CSSfinalizeCssfor the extracted single stylesheetSince
minifyCSSreceives the same config object,build.cssTarget,css.lightningcssandesbuildoptions used during minification now resolve per environment as well.fixes #20789
Tests
Added
cssMinify per environment with shared pluginsnext to the existingminify per environmentandchunkImportMap per environment with shared pluginstests, using a newfixtures/shared-plugins/css-minifyfixture. It builds two client-consumer environments withsharedPlugins: true— one withcssMinify: false, one with the default — and asserts the first emits unminified CSS while the second stays minified.Without the fix the test fails with
expected '.foo{color:red}.bar{color:#00f}' to contain '\n'.