Share Tailwind v3/v4 plugin code in shared_tailwind

QU
1d ago
+269-233

Type of change

Internal refactor, no behavior change.

tailwind_v3.py and tailwind_v4.py carried identical copies of compile_config, add_tailwind_to_css_file, _index_of_element_that_has, pre_compile, get_frontend_development_dependencies and four of their six Constants. AGENTS.md asks to extract duplicated code into parameterized helpers, so these now live once in shared_tailwind:

  • TailwindConstants holds the shared constants. Each version's Constants subclasses it and adds VERSION and ROOT_STYLE_CONTENT.
  • TailwindPlugin implements pre_compile and the dependency list. A version plugin supplies only its root style, its postcss rewrite and its packages.
  • The v4 plugin pinned tailwindcss@4.3.0 and @tailwindcss/postcss@4.3.0 as two literals that were always bumped together. Both now come from one version string.

Verification:

  • Generated output is byte-identical to main for both versions: config, root style with and without Radix, postcss and css rewrites, dependency lists.
  • Module-level names (compile_config, compile_root_style, add_tailwind_to_css_file, add_tailwind_to_postcss_config, Constants) stay importable from tailwind_v3 and tailwind_v4.
  • Adds a test that each plugin wires its own root-style and postcss tasks and pins its packages to a single version.
  • ruff, pyright, ty and the pre-commit hooks pass.

Includes a misc news fragment for reflex-base.

  • Have you written new tests for your core changes, as applicable?
  • Have you successfully ran tests with your changes locally?