Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: support tailwind.css external resourses for Sandpack #8647

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

theshadowagent
Copy link

@theshadowagent theshadowagent commented Oct 31, 2024

Complete Tailwind CSS Play CDN support in Sandpack Bundler

What kind of change does this PR introduce?

Adds complete support for Tailwind CSS Play CDN in Sandpack by properly handling custom Tailwind CSS configs.

What is the current behavior?

Currently, when importing Tailwind Play CDN via externalResources in Sandpack it is impossible to customize Tailwind globals.css config because Sandpack bundler doesn't set the expected type="text/tailwindcss" attribute of the <style>/` tags. This prevents the Tailwind Play CDN (https://cdn.tailwindcss.com) from compiling CSS with custom Tailwind config.

What is the new behavior?

The Sandbox bundler now correctly identifies Tailwind CSS external resourses and sets the expected type="text/tailwindcss" attribute when the external resource file name includes 'tailwind.css'.

This enables:

  • Using custom globals.tailwind.css via externalResources
  • Using custom tailwind.config.js via externalResources

Steps to test

  1. Create a new project with Sandpack's. Pass https://cdn.tailwindcss.com in Sandpack's externalResources
  2. Pass custom tailwind.config.js file to Sandpack's externalResources
  3. Pass globals.tailwind.css to Sandpack's externalResources with custom TailwindCSS styles (same as globals.css in standard Tailwind projects)
  4. Verify that TailwindCSS is loaded properly in Sandpack
  5. Verify that custom Tailwind styles work as expected

Checklist

  • Documentation
  • Testing
  • Ready to be merged
  • Added myself to contributors table (N/A)

Additional Context

This feature is for developers who want to use Tailwind CSS in Sandpack with custom tailwind.config.js and custom globals.css. The Tailwind Play CDN requires type="text/tailwindcss" in <link>/<style> tags to support custom globals.css files, which this PR now supports.

Tailwind CDN docs: https://tailwindcss.com/docs/installation/play-cdn

Copy link

codesandbox bot commented Oct 31, 2024

Review or Edit in CodeSandbox

Open the branch in Web EditorVS CodeInsiders

Open Preview

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