Skip to content

Set build.cssTarget for Tailwind CSS add-on #544

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

Open
hyunbinseo opened this issue Apr 23, 2025 · 0 comments
Open

Set build.cssTarget for Tailwind CSS add-on #544

hyunbinseo opened this issue Apr 23, 2025 · 0 comments
Labels
enhancement New feature or request pkg:add sv add

Comments

@hyunbinseo
Copy link
Contributor

Tailwind CSS now requires Chrome 111+

Tailwind CSS v4.0 is designed for and tested on modern browsers, and the core functionality of the framework specifically depends on these browser versions:

  • Chrome 111 (released March 2023)
  • Safari 16.4 (released March 2023)
  • Firefox 128 (released July 2024)

https://tailwindcss.com/docs/compatibility

However, SvelteKit currently builds on target: 'modules' which targets Chrome 87:

Browser compatibility target for the final bundle. The default value is a Vite special value, 'modules', which targets browsers with native ES Modules, native ESM dynamic import, and import.meta support. Vite will replace 'modules' to ['es2020', 'edge88', 'firefox78', 'chrome87', 'safari14']

https://vite.dev/config/build-options#build-target

This causes Vite to target older browsers with its CSS build output.

This can be fixed by setting Vite's build.cssTarget out-of-the box.

import { sveltekit } from '@sveltejs/kit/vite';
import tailwindcss from '@tailwindcss/vite';
import { defineConfig } from 'vite';

export default defineConfig({
  build: { cssTarget: ['firefox128', 'chrome111', 'safari16.4'] },
  plugins: [tailwindcss(), sveltekit()],
});

Note

Even with this setting, browser native CSS nesting is not flattened since it is supported from Safari 17.2. Reference sveltejs/kit#13732

@manuel3108 manuel3108 added enhancement New feature or request pkg:add sv add labels Apr 24, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request pkg:add sv add
Projects
None yet
Development

No branches or pull requests

2 participants