mirror of
https://github.com/webstudio-is/webstudio.git
synced 2026-12-01 21:05:42 +09:00
Malformed saved CSS can stop a site from publishing. This restores Vite's stylesheet pipeline with Lightning CSS and lets publishing continue when generated CSS is invalid. ## What changed - Save validation uses the shared CSS parser for touched declarations and now rejects malformed style state selectors. The CSS editor already reports malformed pasted declarations and omits them from saved styles. - Publish skips older malformed declarations and warns without including their values. - Generated CSS is imported by Remix, React Router, and Vike, so Vite processes the stylesheet and emits its asset. - Before Vite runs, the CLI checks generated CSS with Lightning CSS and esbuild. If the stylesheet cannot build, it warns and uses preset and font CSS; if that also fails, it uses an empty stylesheet. - The domain publish check parses the current project CSS and shows a warning without blocking publish. The parser catches the malformed cases reproduced with Lightning CSS and esbuild; the CLI's compiler check remains the final guard. It skips malformed declarations just as the CLI does. The early check reads assets and generates and parses CSS once more per validation. Content Block styles created during publishing and static template publishing are covered by the CLI fallback, but not by this early warning. - The temporary hashed public stylesheet path and its larger fixture size allowances are removed. The direct PostCSS dependency remains removed. ## Checklist - [x] Restore Vite CSS imports with Lightning CSS in every site template. - [x] Keep malformed CSS from failing publish and warn when fallback CSS is used. - [x] Test the reported escaped property in React Router and Cloudflare Remix builds. - [x] Test malformed CSS recovery in React Router and Vike builds. - [x] Verify the prerendered Vike page links to the generated CSS asset. - [x] Regenerate fixtures and review the diff. - [x] Review documentation impact: the existing publishing guide needs no change for this warning in the publish flow. - [x] Run CLI typecheck, lint, formatting, package boundaries, CLI build, and frozen lockfile check. - [x] Confirm CSS compiler failure cases with focused tests. - [x] Validate CSS-affecting inputs at save, including style states that bypass the editor picker. - [x] Warn in domain pre-publish validation when current project CSS fails compiler checks. - [x] Verify pasted CSS diagnostics and save behavior in the editor. - [x] Review the new diff and rerun relevant tests, typechecks, and Builder build. - [x] Remove the Builder runtime's native Lightning CSS dependency and test the known compiler failure cases with CSS-tree. - [x] Verify staging Builder and CLI workflows for the latest commit. - [ ] Verify a site publish on staging with a project compatible with this branch. The first attempt used a project with a style source type this branch cannot read. - [x] Reject CSS-tree recoverable parse errors in declaration validation and add a regression test. - [x] Keep project-build within its existing package entrypoints and rerun the affected checks. - [x] Monitor required PR checks to completion. ## Verification Local: affected tests, four package typechecks, Builder and CLI builds, root lint, formatting, package boundaries, and frozen lockfile check passed. The fixture pipeline passed for the earlier commit; this commit changes no fixture inputs or outputs. The new invalid-declaration regression test failed when its filter was removed, then passed when restored. The incomplete `rgb()` parser test failed before the review fix and passed afterward. Full css-data and project-build test suites passed. The Builder runtime uses CSS-tree for the early warning because Vercel omitted Lightning CSS's native binary from the deployed function; the CLI still runs Lightning CSS and esbuild during publishing. The replacement staging deployment, fixture checks, both CLI R2 workflows, main workflow, and all required PR checks passed. Staging publish attempt: CLI sync stopped at `build.styleSources[520]` before CSS generation. This branch accepts only `token` and `local` sources; open PR #6663 adds `tagStyle` and the CSS generation it needs. The failing record could not be read directly with the available share token, so the exact saved type remains unconfirmed. Use a project without Tag styles, or test a combined integration branch after an explicit scope decision. Replaces #6662. --------- Co-authored-by: Codex <codex@users.noreply.github.com>