Tailwind 4 @reference '#tailwindcss' doesn't work when style is <style lang='postcss'>
Nobody has claimed this yet.
Assessment
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Newbie friendliness
- 42/100
- Issue type
- Bug
- Clarity
- Mostly clear
- Activity status
- Stale
- Tech stack
- css, nuxt, tailwind, typescript
- Domain
- build-system, frontend
Research direction
Start with nuxt.config.ts and reproduce the issue in a Vue component using the shown scoped lang="postcss" style block. Compare resolution of @reference '#tailwindcss' with the package.json #importtailwindcss workaround, and verify the fix in production mode; done means nested PostCSS and @apply work without the workaround.
Written by the indexing model from the issue text.
Description
Versions:
"@nuxtjs/tailwindcss": "^7.0.0-beta.0",
"nuxt": "^3.17.5"
nuxt.config.ts
{
postcss: {
plugins: {
"@tailwindcss/postcss": {
optimize: false // also I need to set optimize to false in order to work on production mode
},
"postcss-nested": {},
}
}
}
When the style is set to the following (postcss), then it throws errors or does nothing
<style lang='postcss' scoped>
@reference '#tailwindcss';
.ct-base__item{
@apply flex;
&--red{
@apply text-red-500;
}
}
</style>
The workaround I found is to set the following in package.json
"imports": {
"#importtailwindcss": "./app/assets/css/tailwind.css"
}
Then in Vue file, I can use @reference '#importtailwindcss' to make it work again.
<style lang='postcss' scoped>
@reference '#importtailwindcss';
.ct-base__item{
@apply flex;
&--red{
@apply text-red-500;
}
}
</style>
Or not using PostCSS also works but I cannot use nested feature
<style lang='css' scoped>
@reference '#tailwindcss';
.ct-base__item{
@apply flex;
}
.ct-base__item--red{
@apply text-red-500;
}
</style>
Anyone else having the same issue?
also to make postcss work on production see this thread
- Dominant language
- TypeScript
- Stars
- 1.9k
- Forks
- 192
- PR merge metrics
- No merged PRs in 30d
Contributor guide
No contributing guide indexed for this repository
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
More from nuxt-modules/tailwindcss
-
Version 6 Openbug
Difficulty 4/5 3-5 days Newbie friendliness 35/100
nuxt-modules/tailwindcss#1042 ·
-
bug
Difficulty 3/5 1-2 days Newbie friendliness 35/100
nuxt-modules/tailwindcss#1039 · 2 comments ·
-
bug
Difficulty 3/5 1-2 days Newbie friendliness 45/100
nuxt-modules/tailwindcss#1034 · 1 comment ·
-
bug
Difficulty 3/5 1-2 days Newbie friendliness 35/100
nuxt-modules/tailwindcss#1033 · 1 comment ·
-
question
Difficulty 3/5 1-2 days Newbie friendliness 30/100
nuxt-modules/tailwindcss#1031 · 7 comments ·
All issues in nuxt-modules/tailwindcss
Similar issues
-
comp/dashboard P3 type/bug
Difficulty 2/5 1-3 hours Newbie friendliness 86/100
NousResearch/hermes-agent#117722 ·
-
clawsweeper:fix-shape-clear clawsweeper:queueable-fix clawsweeper:source-repro impact:ux-friction issue-rating: 🦞 diamond lobster no-stale P3
Difficulty 2/5 1-3 hours Newbie friendliness 78/100
-
community first-timers-only good first issue hacktoberfest help wanted low hanging fruit up-for-grabs
Difficulty 1/5 Under an hour Newbie friendliness 76/100
-
code-quality refactoring
Difficulty 2/5 1-3 hours Newbie friendliness 84/100
github/gh-aw-firewall#8816 ·
-
integration:quickjs org:external priority:backlog topic:code-interpreter topic:middleware type:feature
Difficulty 2/5 1-3 hours Newbie friendliness 74/100
langchain-ai/deepagents#6450 ·