multipleTailwindConfigPlugin.js 797 B

123456789101112131415161718
  1. // Copyright (C) 2012-2024 Zammad Foundation, https://zammad-foundation.org/
  2. const tailwindcss = require('tailwindcss')
  3. const { minimatch } = require('minimatch')
  4. const mobileConfig = require('../apps/mobile/styles/tailwind.mobile.js')
  5. const desktopConfig = require('../apps/desktop/styles/tailwind.desktop.js')
  6. /** @type {import('postcss').TransformCallback} */
  7. module.exports = (root, result) => {
  8. // Check the current module against content globs in available app-specific Tailwind configs.
  9. // This avoids the build issue with the wrong Tailwind config being applied.
  10. if (
  11. mobileConfig.content.some((glob) => minimatch(root.source.input.file, glob))
  12. )
  13. return tailwindcss(mobileConfig).plugins[0](root, result)
  14. return tailwindcss(desktopConfig).plugins[0](root, result)
  15. }