multipleTailwindConfigPlugin.js 798 B

12345678910111213141516171819
  1. // Copyright (C) 2012-2024 Zammad Foundation, https://zammad-foundation.org/
  2. const { minimatch } = require('minimatch')
  3. const tailwindcss = require('tailwindcss')
  4. const desktopConfig = require('../apps/desktop/styles/tailwind.desktop.js')
  5. const mobileConfig = require('../apps/mobile/styles/tailwind.mobile.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. }