Skip to content

fix: resolve string template CSS imports from config.root - #1916

Merged
cossssmin merged 1 commit into
masterfrom
fix/string-template-root
Oct 8, 2026
Merged

cossssmin merged 1 commit into
masterfrom
fix/string-template-root

Conversation

@cossssmin

@cossssmin cossssmin commented Oct 8, 2026 •

Copy link
Copy Markdown
Member

Fixes #1914

When render() gets an SFC string instead of a file path, the Tailwind transformers compiled its CSS with from set to process.cwd()/template.vue, ignoring config.root. Servers whose working directory can't resolve @maizzle/tailwindcss (e.g. a Nitro build started from /app) failed with Can't resolve '@maizzle/tailwindcss' and returned the email unstyled.

Changes

  • tailwindcss and tailwindComponent transformers now fall back to config.root ?? process.cwd(), same as the linter and compatibility checker. No change for callers that don't pass root
  • resolveMaizzleImports now runs in Once instead of as an AtRule visitor. PostCSS runs every plugin's Once before any visitor, and @tailwindcss/postcss resolves imports in its own Once, so the rewrite to an absolute path always came too late. It also gets config.root now instead of defaulting to cwd
  • With both in place, @maizzle/tailwindcss resolves even when neither cwd nor root can, by falling back to the copy bundled with the framework

Tests

  • tailwindcss without a filePath, from a cwd that can't resolve anything: relative imports resolve from config.root, and @maizzle/tailwindcss resolves even when root can't
  • tailwindComponent: relative imports resolve from config.root
  • resolveMaizzleImports: the rewrite is visible to a later plugin's Once hook

🤖 Generated with Claude Code

Summary by CodeRabbit

  • Bug Fixes
    • Tailwind now resolves templates and relative imports from the configured project root when no file path is provided, falling back to the current working directory when no root is configured.
    • Maizzle imports are resolved before other PostCSS plugins inspect them, improving compatibility with Tailwind import resolution.

Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
@coderabbitai

coderabbitai Bot commented Oct 8, 2026 •

Copy link
Copy Markdown

Review in Change Stack →

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration
  • Configuration used: Organization UI
  • Review profile: CHILL
  • Plan: Advanced
  • Run ID: 190281c6-19bc-4323-a4dc-9bc1fee5ed66
📥 Commits

Reviewing files that changed from the base of the PR and between da3bff6 and d2b8df0.

📒 Files selected for processing (7)
  • src/plugins/postcss/resolveMaizzleImports.ts
  • src/tests/plugins/resolveMaizzleImports.test.ts
  • src/tests/transformers/tailwindComponent.test.ts
  • src/tests/transformers/tailwindcss.test.ts
  • src/transformers/tailwindComponent.ts
  • src/transformers/tailwindcss.ts
  • src/utils/compileTailwindCss.ts

Included review availability: This review used your included allowance. Your plan provides up to 4 included reviews per hour; 2 remain after this review.


📝 Walkthrough

Walkthrough

Tailwind transformers now use config.root for default template paths. The PostCSS import resolver receives that root and rewrites matching imports during its Once hook, before plugin visitors run. Tests cover root-based import resolution and hook order.

Changes

Tailwind import resolution

Layer / File(s) Summary
Resolve default template paths from config.root
src/transformers/tailwindComponent.ts, src/transformers/tailwindcss.ts, src/tests/transformers/tailwindComponent.test.ts, src/tests/transformers/tailwindcss.test.ts
When filePath is absent, both transformers use config.root for the default template path when set, and otherwise use the current working directory. Tests cover resolving relative imports from config.root.
Rewrite Maizzle imports before plugin visitors
src/utils/compileTailwindCss.ts, src/plugins/postcss/resolveMaizzleImports.ts, src/tests/plugins/resolveMaizzleImports.test.ts, src/tests/transformers/tailwindcss.test.ts
createTailwindProcessor passes config.root to resolveMaizzleImports. The resolver walks import at-rules in PostCSS's Once hook. Tests check that a later Once hook sees the rewritten path and that @maizzle/tailwindcss resolves when the working directory and root cannot resolve it.

Priority: ➖ Normal

Estimated code review effort: 2 (Simple) | ~10 minutes

Change: Bug fix · Severity of issue fixed: Medium

Merge Risk: ⚪ Minimal · up to d2b8d

String templates rendered with a configured root should now resolve Tailwind CSS imports from that root. Callers without a root keep the existing behavior. No merge-blocking risk was identified.

🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 60.00% which is insufficient. The required threshold is 80.00%. Docstring coverage is scoped to functions touched by this diff. Analyzed 5 functions across 7 files. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (4 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title clearly and concisely describes the main change: resolving string-template CSS imports from config.root.
Linked Issues check ✅ Passed The changes satisfy active issue #1914. tailwindcss uses resolve(config.root ?? process.cwd(), 'template.vue') when no file path exists. tailwindComponent applies the same fallback. `createTailw…
Out of Scope Changes check ✅ Passed The reviewed changes stay within issue #1914. The source edits change only string-template path selection, Maizzle import resolution timing and root selection, and the related processor call. The adde…
  • Fix all pre-merge checks with AI
✨ Finishing Touches 💡 1
📝 Generate docstrings 💡
  • Commit to this branch
  • Create a new PR
🧪 Generate unit tests (beta)
  • Commit to this branch
  • Create a new PR
  • Autopilot · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

@cossssmin
cossssmin merged commit e2df83b into master Oct 8, 2026
6 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.

render() with a string template resolves Tailwind @imports from process.cwd(), ignoring config.root

1 participant