Skip to content
Merged
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -97,7 +97,8 @@
"packageManager": "pnpm@9.15.3",
"resolutions": {
"@nuxtjs/tailwindcss": "link:.",
"@nuxt/ui": "npm:@nuxt/ui-edge"
"@nuxt/ui": "npm:@nuxt/ui-edge",
"unicorn-magic": "0.2.0"
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hi @ineshbose, do you happen to have more info on why this resolution is necessary? I noticed after updating to 6.14.0 that the docker builds for our app broke, but adding this resolution to our package.json fixed things. But that was just a random troubleshooting step, and I'd be curious about the root cause.

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hey - yes it is an odd issue. You can do down this thread to investigate #954, but even I would be slightly confused 😅

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks!

},
"stackblitz": {
"startCommand": "pnpm dev:prepare && pnpm dev"
Expand Down
5 changes: 3 additions & 2 deletions playground/tailwind.config.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
import typography from '@tailwindcss/typography'
import colors from 'tailwindcss/colors'
import { defineConfig } from '../src/config'

export default {
export default defineConfig({
theme: {
extend: {
colors: {
Expand All @@ -15,4 +16,4 @@ export default {
plugins: [
typography(),
],
}
})
11 changes: 6 additions & 5 deletions pnpm-lock.yaml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

13 changes: 12 additions & 1 deletion src/config.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,16 @@
import { fileURLToPath } from 'node:url'
import { resolve } from 'pathe'
import { createDefineConfig } from 'c12'
import { tryUseNuxt, requireModule } from '@nuxt/kit'
import type { Config } from 'tailwindcss'

export const defineConfig = createDefineConfig<Partial<Config>>()
const pathToThisFile = resolve(fileURLToPath(import.meta.url))
const pathPassedToNode = resolve(process.argv[1])
const isMainFile = pathToThisFile.includes(pathPassedToNode)

const _defineConfig = createDefineConfig<Partial<Config>>()
export const defineConfig: typeof _defineConfig = (config) => {
const isNuxt = !!tryUseNuxt()
return isNuxt ? config : isMainFile ? requireModule('.nuxt/tailwind/postcss.mjs') : config
Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@danielroe

Could I get a review here possibly?

The use-case is for IntelliSense - if it is used in Nuxt build-time, just return the defined config.

If it is being loaded from the IntelliSense plugin, return .nuxt/tailwind/postcss.mjs contents which will in-turn re-import this file/config, so if it is being imported from there, return the object instead of trying to re-require postcss.mjs causing a cyclic import.

Quite fragile stuff, but I'm thinking I could ship it and based on feedback, remove it if not helpful as it is a non-app functionality feature/change.

}
export default defineConfig