Skip to content

fix(build): resolve esbuild CSS syntax warnings in drafts widget notices - #1046

Merged
epeicher merged 1 commit into
WordPress:trunkfrom
KarunyaChavan:fix/drafts-widget-css-selector-syntax
Oct 30, 2026
Merged

epeicher merged 1 commit into
WordPress:trunkfrom
KarunyaChavan:fix/drafts-widget-css-selector-syntax

Conversation

@KarunyaChavan

@KarunyaChavan KarunyaChavan commented Oct 23, 2026 •

Copy link
Copy Markdown
Contributor

This pull request eliminates the three [css-syntax-error] Expected identifier but found whitespace warnings emitted by esbuild during production CSS minification of the drafts widget. By removing inner whitespace from attribute selectors ([ tone=... ]) in src/plugins/drafts-widget/styles.css and updating the tracked build outputs, the CSS now adheres to standard selector syntax and builds cleanly without warnings.

Closes #1044

Why ?

  • Parser Strictness: Vite uses esbuild for CSS minification during production builds (npm run build / npm run build:widget-drafts).
  • Syntax Error Cause: In src/plugins/drafts-widget/styles.css, selectors were written with spaces inside the brackets (e.g., .dm-drafts__notice[ tone='success' ]). Esbuild's CSS parser strictly expects an attribute identifier token immediately after [ and flags any leading whitespace as a [css-syntax-error].
  • Build Health: While browsers parse spaced brackets leniently, the syntax errors create noisy build logs and risk breaking future minifier releases or strict CI environments.

What Changed ?

  • src/plugins/drafts-widget/styles.css:
    • Removed inner whitespace from [tone='success'], [tone='warning'], [tone='error'], and [tone='danger'] attribute selectors.
  • assets/js/widget-drafts.css:
    • Recompiled the unminified bundle loaded when SCRIPT_DEBUG is active.
  • assets/js/widget-drafts.min.css:
    • Recompiled the production minified bundle; because esbuild can now parse the selector cleanly, it optimizes the attributes to unquoted identifier form ([tone=success]).

Steps for Testing

  • Verify Clean Build:
    • Run npm run build:widget-drafts (or npm run build).
    • Confirm the build succeeds with 0 warnings and no [css-syntax-error] messages during the minification step.
  • Run Unit Tests:
    • Run npm run test:js -- tests/vitest/drafts-widget.test.ts.
    • Confirm all tests pass.
Open WordPress Playground Preview

…ces.

- Remove inner whitespace from attribute selectors (`[ tone=... ]`) in `src/plugins/drafts-widget/styles.css`.
- esbuild's CSS minifier parser rejects whitespace immediately following the opening bracket in attribute selectors, logging `[css-syntax-error]` warnings during production builds.
- Removes the whitespace so the rules parse cleanly, letting esbuild minify them normally with unquoted identifier normalization `[tone=success]`). Also updates the tracked built CSS assets.
@KarunyaChavan
KarunyaChavan marked this pull request as ready for review October 23, 2026 11:43

@epeicher epeicher left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks @KarunyaChavan for fixing those! I have reviewed the changes and they LGTM!

@epeicher
epeicher merged commit bab2b18 into WordPress:trunk Oct 30, 2026
7 checks passed
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.

CSS minification syntax warning in drafts widget attribute selectors

2 participants