Skip to content

CSS is 254KB of unused classes #1916

Description

@FedericoGarciaGarcia

Description

I followed exactly each step of the guide making a fresh new Svelte (not Sveltekit) project and the generated CSS file in dist/assets is 254KB.

I didn't import any Flowbite components or used any Tailwind classes, yet the generated CSS file is including pretty much all of Tailwind.

The FAQ mentions using PurgeCSS in these cases, but it seems the npm package cannot be installed, my understanding is it's meant for Tailwind v3 but Flowbite uses v4 (I think?), which should already be including only the necessary CSS in the build:

npm error  dev tailwindcss@"^4.1.17" from the root project
npm error Could not resolve dependency:
npm error peer tailwindcss@"^3.3.0" from vite-plugin-tailwind-purgecss@0.3.5

This is the app.css

@import "tailwindcss";
@plugin '@tailwindcss/forms';
@plugin '@tailwindcss/typography';
@plugin 'flowbite/plugin';
@custom-variant dark (&:where(.dark, .dark *));

@source "../node_modules/flowbite-svelte/dist";
@source "../node_modules/flowbite-svelte-icons/dist";

This is App.svelte

<script>
  import "./app.css";
</script>

Hello

Is there any step I'm missing?

Minimal Reproduction

// About compilation, not code

Steps to Reproduce

  1. Follow guide making a fresh new Svelte (not Sveltekit) project: https://flowbite-svelte.com/docs/pages/quickstart
  2. Run npm run build
  3. CSS file in dist/assets is 254KB

Environment

System:
    OS: Linux 5.15 Debian GNU/Linux 12 (bookworm) 12 (bookworm)
    CPU: (10) arm64 unknown
    Memory: 7.96 GB / 23.45 GB
    Container: Yes
    Shell: 5.2.15 - /bin/bash
  Binaries:
    Node: 22.21.1 - /usr/local/share/nvm/versions/node/v22.21.1/bin/node
    Yarn: 1.22.22 - /usr/bin/yarn
    npm: 10.9.4 - /usr/local/share/nvm/versions/node/v22.21.1/bin/npm
    pnpm: 10.26.2 - /usr/local/share/nvm/versions/node/v22.21.1/bin/pnpm
  npmPackages:
    flowbite: ^4.0.1 => 4.0.1 
    flowbite-svelte: ^1.31.0 => 1.31.0 
    svelte: ^5.46.1 => 5.46.1 
    vite: ^6.4.1 => 6.4.1

Relevant Logs / Console Output

Screenshots / GIF (optional)

No response

Additional Context (optional)

No response

Checklist

  • I have searched existing issues and discussions
  • I have provided a minimal and runnable reproduction
  • I am using the latest version of Flowbite-Svelte

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions