Skip to content

Add app.css alias for Tailwind CSS v4 add-on #515

Closed as not planned
Closed as not planned
@hyunbinseo

Description

@hyunbinseo

There is a heated discussion related to using the @apply directive in a Svelte component:

Without the @reference directive, the following error occurs:

[plugin:@tailwindcss/vite:generate:serve]
Error: Cannot apply unknown utility class: text-red-700

I personally believe this is the best workaround:

// svelte.config.js
const config = {
  kit: {
    // ...
    alias: { '$app.css': './src/app.css' },
  },
};

export default config;
<style>
  @reference "$app.css";
  a {
    @apply text-red-700;
  }
</style>

The ./src/app.css will be hard-coded to the Prettier config file as well, so I guess it can be safely aliased.

Note

I do understand that this is only needed for people using the @apply directive, but this seemed to be the desirable place to leave this content.

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions