feat(css): migrate CSS build from webpack to Vite - #13326
Merged
Conversation
Replace webpack.config.css.js with vite-css.config.mjs for the CSS build (17 entries, minified). Preserve url(/static/...) references via a PostCSS Once-hook passthrough, and hoist all mid-file @imports to the top (webpack output proven byte-identical before/after). Vite builds ~3.7x faster on host. Remove mini-css-extract-plugin, css-minimizer-webpack-plugin, and glob deps; update docs.
Add a repo-local stylelint rule (ol/import-at-top) that flags any @import after the first statement in a CSS file. The Vite build silently drops mid-file @imports, so this alerts in CI (npm run lint), the pre-commit stylelint hook, and editors. Registered in .stylelintrc.json and covered by jest tests that run the real stylelint CLI.
β¦build Two pieces of custom code in vite-css.config.mjs turned out to be unnecessary: - @charset restoration: legacy.css's `@charset "utf-8";` was removed from source to silence postcss-import warnings, so the ~45-line import-graph walk + closeBundle re-add that restored it into outputs was pure byte-parity chasing. Vite natively strips the declaration; it's meaningless for HTTP-served CSS (charset comes from headers, utf-8 is the default). Output now simply lacks it (~16B smaller on the 7 legacy-importing files). - removeCompanionJsChunks: Vite 8 omits the empty JS stub chunk for pure-CSS entries natively, making the plugin dead code. A closeBundle regression guard now warns if stray .js files appear in the CSS output (a future Vite upgrade could stop omitting them), matching the existing data:image/__OL__ guard philosophy. Docs updated in docs/ai/css-vite-migration.md. Build verified: `make css` clean, /static/ url parity vs webpack unchanged, no data URIs or placeholders, gzip ~16B smaller, eslint/stylelint clean, jest 5/5.
cdrini
approved these changes
Aug 13, 2026
cdrini
left a comment
Collaborator
There was a problem hiding this comment.
Went through the site on testing a few times and not seeing any CSS issues. Love the speed improvements! Approach looks good to me.
Collaborator
There was a problem hiding this comment.
I don't think there's a lot of value in committing this historical doc here? The docs in css.md are sufficient.
Collaborator
|
Oh whoops sorry meant to just communicate it lgtm :D I think @lokesh should have a chance to provide feedback as well since he's assigned and more directly impacted by these changes! |
This was referenced Aug 26, 2026
Closed
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.
Replaces
webpack.config.css.jswithvite-css.config.mjs, building the same 17 CSS entries with@importresolution, esbuild minification, andurl()passthrough parity.Speed Improvements :
@imports to the top of affected CSS files (invalid per spec, silently dropped by Vite) β output verified byte-identical to webpack'sol/import-at-top(+ unit tests) so a regression failsnpm run lint, not just the buildnpm run watchnow streams both webpack and Vite output;clearScreen: falsestops Vite wiping the shared terminalmodeinstead ofNODE_ENV; regression guards on the url passthrough now fail the build/static/references, selector sets, and gzip sizes (within 1KB) vs webpack; allbundlesizechecks passAs far as I can tell there are no regressions at all. The only weirdness is that we set this public directory to the root because we don't want them rewriting our urls since we don't bundle in images.