From fb28b232b34b2b15ae910104025229301bff3709 Mon Sep 17 00:00:00 2001 From: Cosmin Popovici Date: Sun, 2 Oct 2022 16:24:28 +0300 Subject: [PATCH] fix: use postcss import only if build tailwind.css exists --- src/generators/tailwindcss.js | 20 ++++++++++++-------- 1 file changed, 12 insertions(+), 8 deletions(-) diff --git a/src/generators/tailwindcss.js b/src/generators/tailwindcss.js index 5c1bd2a0..0d9089f6 100644 --- a/src/generators/tailwindcss.js +++ b/src/generators/tailwindcss.js @@ -89,19 +89,23 @@ module.exports = { const userFilePath = get(maizzleConfig, 'build.tailwind.css', path.join(process.cwd(), 'src/css/tailwind.css')) const userFileExists = await fs.pathExists(userFilePath) + const toProcess = [ + postcssNested(), + tailwindcss(config), + maizzleConfig.env === 'local' ? () => {} : mergeLonghand(), + ...get(maizzleConfig, 'build.postcss.plugins', []) + ] + if (userFileExists) { css = await fs.readFile(path.resolve(userFilePath), 'utf8') + css + toProcess.unshift( + postcssImport({path: path.dirname(userFilePath)}) + ) } else { - css = `@import "tailwindcss/components"; @import "tailwindcss/utilities"; ${css}` + css = `@tailwind components; @tailwind utilities; ${css}` } - return postcss([ - postcssImport({path: path.dirname(userFilePath)}), - postcssNested(), - tailwindcss(config), - maizzleConfig.env === 'local' ? () => {} : mergeLonghand(), - ...get(maizzleConfig, 'build.postcss.plugins', []) - ]) + return postcss([...toProcess]) .process(css, {from: undefined}) .then(result => result.css) .catch(error => {