tailwindcss/integrations/vite
Philipp Spiess c72c83fee3
Vite: Support Tailwind in Svelte <style> blocks (#14151)
Closes #13305

This PR adds registers a Svelte preprocessor, used by the Svelte Vite
plugin, to run Tailwind CSS for styles inside the `<style>` block, this
enables users to use Tailwind CSS features like `@apply` from inside
Svelte components:


```svelte
<script>
  let name = 'world'
</script>
<h1 class="foo underline">Hello {name}!</h1>
<style global>
  @import 'tailwindcss/utilities';
  @import 'tailwindcss/theme' theme(reference);
  @import './components.css';
</style>
```

## Test Plan

I've added integration tests to validate this works as expected.
Furthermore I've used the
[tailwindcss-playgrounds](https://github.com/philipp-spiess/tailwind-playgrounds)
SvelteKit project to ensure this works in an end-to-end setup:

<img width="2250" alt="Screenshot 2024-11-08 at 14 45 31"
src="https://github.com/user-attachments/assets/64e9e0f3-53fb-4039-b0a7-3ce945a29179">
2024-11-08 20:01:16 +01:00
..
astro.test.ts Revert "Fix Astro integration test by pinning zod-to-json-schema" (#14792) 2024-10-25 11:31:34 +02:00
config.test.ts Integration tests: Move all file writes into retry block (#14350) 2024-09-06 10:48:49 +02:00
css-modules.test.ts Don't assert on mangled CSS names (#14397) 2024-09-11 17:37:36 +02:00
index.test.ts Remove fallbacks from theme var(...) calls (#14881) 2024-11-05 15:44:21 -05:00
multi-root.test.ts Add integration tests for multi-root builds (#14564) 2024-10-01 17:00:20 +02:00
nuxt.test.ts Fix glob pattern hoisting on Windows (#14904) 2024-11-07 15:31:06 -05:00
other-transforms.test.ts Apply non-Tailwind CSS transforms in Vite plugin (#14871) 2024-11-07 16:26:18 +01:00
svelte.test.ts Vite: Support Tailwind in Svelte <style> blocks (#14151) 2024-11-08 20:01:16 +01:00
url-rewriting.test.ts Rewrite urls in CSS files when using Vite (#14877) 2024-11-07 09:51:58 -05:00
vue.test.ts Apply non-Tailwind CSS transforms in Vite plugin (#14871) 2024-11-07 16:26:18 +01:00