Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: append to postcss options and use new nuxt 3 schema #437

Merged
merged 4 commits into from
Mar 14, 2022
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
18 changes: 7 additions & 11 deletions src/module.ts
Original file line number Diff line number Diff line change
Expand Up @@ -94,20 +94,16 @@ export default defineNuxtModule({

// Setup postcss plugins
// https://tailwindcss.com/docs/using-with-preprocessors#future-css-features
const postcssPlugins = {
'postcss-nesting': {},
'postcss-custom-properties': {},
tailwindcss: tailwindConfig
}
const postcssOptions =
nuxt.options.postcss || /* nuxt 3 */
nuxt.options.build.postcss.postcssOptions || /* older nuxt3 */
nuxt.options.build.postcss as any
postcssOptions.plugins['tailwindcss/nesting'] = postcssOptions.plugins['tailwindcss/nesting'] ?? {}
postcssOptions.plugins['postcss-custom-properties'] = postcssOptions.plugins['postcss-custom-properties'] ?? {}
postcssOptions.plugins.tailwindcss = tailwindConfig

if (isNuxt2()) {
const postcssOptions = nuxt.options.build.postcss as any
postcssOptions.plugins = defu(postcssOptions.plugins, postcssPlugins)
await installModule('@nuxt/postcss8')
} else {
const postcssOptions = nuxt.options.build.postcss.postcssOptions
postcssOptions.plugins = postcssOptions.plugins || {}
postcssOptions.plugins = defu(postcssOptions.plugins, postcssPlugins)
}

// Add _tailwind config viewer endpoint
Expand Down
Loading