Skip to content
Merged
Show file tree
Hide file tree
Changes from all 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
11 changes: 9 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,11 @@
"types": "./dist/merger.d.ts",
"require": "./dist/merger.cjs",
"import": "./dist/merger.mjs"
},
"./config-ctx": {
"types": "./dist/config-ctx.d.ts",
"require": "./dist/config-ctx.cjs",
"import": "./dist/config-ctx.mjs"
}
},
"main": "./dist/module.cjs",
Expand All @@ -34,7 +39,8 @@
"build": {
"entries": [
"./src/config",
"./src/merger"
"./src/merger",
"./src/config-ctx"
],
"externals": [
"@tailwindcss/vite"
Expand Down Expand Up @@ -101,7 +107,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(),
],
}
})
31 changes: 13 additions & 18 deletions pnpm-lock.yaml

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

3 changes: 3 additions & 0 deletions src/config-ctx.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
import { ctx } from './config'

ctx.set(true)
10 changes: 9 additions & 1 deletion src/config.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,13 @@
import { createDefineConfig } from 'c12'
import { getContext } from 'unctx'
import { tryUseNuxt, requireModule } from '@nuxt/kit'
import type { Config } from 'tailwindcss'

export const defineConfig = createDefineConfig<Partial<Config>>()
export const ctx = getContext<boolean>('tw-config-ctx')

const _defineConfig = createDefineConfig<Partial<Config>>()
export const defineConfig: typeof _defineConfig = (config) => {
const isNuxt = !!tryUseNuxt()
return isNuxt || ctx.tryUse() ? config : requireModule('.nuxt/tailwind/postcss.mjs')
}
export default defineConfig
1 change: 1 addition & 0 deletions src/internal-context/load.ts
Original file line number Diff line number Diff line change
Expand Up @@ -216,6 +216,7 @@ const createInternalContext = async (moduleOptions: ModuleOptions, nuxt = useNux

return [
`// generated by the @nuxtjs/tailwindcss <https://github.com/nuxt-modules/tailwindcss> module at ${(new Date()).toLocaleString()}`,
'import "@nuxtjs/tailwindcss/config-ctx"',
`import configMerger from "@nuxtjs/tailwindcss/merger";\n`,
layerConfigs.map(([i, _]) => i).filter(Boolean).join(';\n') + ';',
'const config = [',
Expand Down