Closed as not planned
Description
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.