Skip to content

Commit fed1c31

Browse files
authoredMar 14, 2022
fix: append to postcss options and use new nuxt 3 schema (#437)
1 parent bba6b4d commit fed1c31

File tree

2 files changed

+788
-1395
lines changed

2 files changed

+788
-1395
lines changed
 

‎src/module.ts

+7-11
Original file line numberDiff line numberDiff line change
@@ -94,20 +94,16 @@ export default defineNuxtModule({
9494

9595
// Setup postcss plugins
9696
// https://tailwindcss.com/docs/using-with-preprocessors#future-css-features
97-
const postcssPlugins = {
98-
'postcss-nesting': {},
99-
'postcss-custom-properties': {},
100-
tailwindcss: tailwindConfig
101-
}
97+
const postcssOptions =
98+
nuxt.options.postcss || /* nuxt 3 */
99+
nuxt.options.build.postcss.postcssOptions || /* older nuxt3 */
100+
nuxt.options.build.postcss as any
101+
postcssOptions.plugins['tailwindcss/nesting'] = postcssOptions.plugins['tailwindcss/nesting'] ?? {}
102+
postcssOptions.plugins['postcss-custom-properties'] = postcssOptions.plugins['postcss-custom-properties'] ?? {}
103+
postcssOptions.plugins.tailwindcss = tailwindConfig
102104

103105
if (isNuxt2()) {
104-
const postcssOptions = nuxt.options.build.postcss as any
105-
postcssOptions.plugins = defu(postcssOptions.plugins, postcssPlugins)
106106
await installModule('@nuxt/postcss8')
107-
} else {
108-
const postcssOptions = nuxt.options.build.postcss.postcssOptions
109-
postcssOptions.plugins = postcssOptions.plugins || {}
110-
postcssOptions.plugins = defu(postcssOptions.plugins, postcssPlugins)
111107
}
112108

113109
// Add _tailwind config viewer endpoint

‎yarn.lock

+781-1,384
Large diffs are not rendered by default.

0 commit comments

Comments
 (0)
Please sign in to comment.