Skip to content

Move theme-css docs to a dedicated file and auto-run on npm run dev - #123

Open
dmytrobez wants to merge 2 commits into
futurefrom
feat/css-vars-from-theme-feedback
Open

Move theme-css docs to a dedicated file and auto-run on npm run dev#123
dmytrobez wants to merge 2 commits into
futurefrom
feat/css-vars-from-theme-feedback

Conversation

@dmytrobez

Copy link
Copy Markdown

Applies team feedback on the original feat/generate-css-vars-from-theme work (already merged into future).

Feedback addressed

  1. Docs were in the wrong place. The 6-line stub in wordpress/README.md pointed nowhere useful, while the substantive how-to (local dev, CI overview, troubleshooting) was buried under a "Theme CSS Generation" section inside docs/setup/deployment.md. A developer looking for "how do I refresh the theme CSS locally?" would never open the deployment doc.
  2. No auto-run when webpack (re)starts. The script only fired in CI or via manual npm run generate:theme-css. Team suggestion: run it automatically when webpack restarts.

Changes

Docs consolidation

  • New: docs/setup/theme-css.md — canonical doc (what it is, local dev with auto-run, CI overview, files, troubleshooting).
  • wordpress/README.md: stub replaced with a one-line pointer.
  • docs/setup/deployment.md: trimmed the Theme CSS section to CI-specific content only + a link to the new doc.

Auto-run on npm run dev

  • Added predev in wordpress/package.json — regenerates the CSS before webpack starts.
  • Added a THEME_CSS_SOFT=1 branch in wordpress/scripts/theme-css.sh so the predev hook doesn't block dev when WordPress isn't reachable (e.g. before npm start). Manual invocation of generate:theme-css keeps the original strict behavior.

Test plan

  • Run npm --prefix wordpress run dev with WP up — see "Full theme CSS generated (X KB)" before webpack starts.
  • Run npm --prefix wordpress run dev with WP down — see the skip message and confirm webpack still starts.
  • Run WPCLI="wp @local" npm --prefix wordpress run generate:theme-css with WP down — must still exit 1 (manual mode stays strict).
  • Open docs/setup/theme-css.md and confirm a fresh reader can answer "how do I refresh the CSS locally?" without leaving the page.

dmytrobez added 2 commits July 1, 2026 11:40
The substantive how-to (local dev, CI overview, troubleshooting) was
previously split between a stub in wordpress/README.md and a section
buried inside docs/setup/deployment.md. Move it to a dedicated file
and reduce the old locations to pointers / CI-only content.
Add a predev hook in wordpress/package.json that runs
generate:theme-css before webpack starts, so developers no longer
need to remember it manually.

To keep the hook from blocking dev when WordPress is not reachable
(e.g. before npm start), introduce a THEME_CSS_SOFT env flag in
theme-css.sh that converts the unreachable-WP error into a warning
and exits 0. Other errors (empty CSS output, etc.) still hard-fail.

Manual invocation of generate:theme-css keeps the original strict
behavior since THEME_CSS_SOFT is only set by the predev hook.
@dmytrobez
dmytrobez requested a review from charl0tee July 1, 2026 09:44
@dmytrobez dmytrobez self-assigned this Jul 1, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant