diff --git a/lib/module.js b/lib/module.js index cd876c82..03b9ff98 100644 --- a/lib/module.js +++ b/lib/module.js @@ -30,9 +30,17 @@ module.exports = async function (moduleOptions) { /* ** Set PostCSS config (before nuxt-purgecss) */ - this.options.build.postcss.preset.stage = 1 // see https://tailwindcss.com/docs/using-with-preprocessors#future-css-features - this.options.build.postcss.plugins = this.options.build.postcss.plugins || {} - this.options.build.postcss.plugins.tailwindcss = this.options.build.postcss.plugins.tailwindcss || configPath + const { postcss } = this.options.build + + postcss.preset.stage = 1 // see https://tailwindcss.com/docs/using-with-preprocessors#future-css-features + postcss.plugins = postcss.plugins || {} + + if (Array.isArray(postcss.plugins)) { + postcss.plugins.push(require('tailwindcss')(configPath)) + } else if (typeof postcss.plugins === 'object') { + postcss.plugins.tailwindcss = postcss.plugins.tailwindcss || configPath + } + /* ** Add nuxt-purgecss module and set config ** only for `nuxt build` command