multipleTailwindConfigPlugin.js 915 B

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