sveltejs / sveltejs/kit

Allow using build.cssCodeSplit option in vite.config

Open
#10,109 5 comments 13 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

blocked by upstream vite
Dominant language
JavaScript
Stars
20.8k
Forks
2.3k
Avg merge
1d 16h
Merged PRs (30d)
156

Description

Describe the problem

I use Tailwind to style my SvelteKit application. 95% of the styles end up in one CSS file. However, for some components, Tailwind utilities are not sufficient, and I write custom CSS.

These custom CSS styles are minimal, yet they end up in a separate CSS file, requiring an additional request. This happens for each component that requires custom styling.

Vite provides an option to turn off css code splitting with cssCodeSplit. However, this option is overridden by SvelteKit and cannot be turned off.

Describe the proposed solution

I would like to be able to turn off cssCodeSplit in vite config.

Alternatives considered

I could define my custom styles in my tailwind styles, then they'll end up in one file. However, I'd like to keep the styles and the components together.

Importance

would make my life easier

Additional Information

This issue has been brought up in a discussion before, where the problem is explain well.

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start by tracing how SvelteKit handles Vite's build.cssCodeSplit option and compare that behavior with the linked Vite configuration documentation. Verify the result by building an application with component CSS and checking whether the generated styles are combined as requested.

Written by the indexing model from the issue text.

Assessment

Tech stack
javascript, tailwindcss, vite
Domain
build-system, frontend, web-dev
Issue type
Feature
Difficulty
3/5
Estimated time
1-2 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
42/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.