'How to track every PHP file located in a folder with Tailwind CSS

I am using Tailwind CSS in my projects and I want to include all of my PHP files in tailwind.config.js file. I want to use wildcards, but it doesn't seem to work.

This works:

module.exports = {
  content: [
    "./${themePath}/index.php",
    "./${themePath}/header.php",
    "./${themePath}/footer.php",
  ],
}

This doesn't:

module.exports = {
  content: [
    "./${themePath}/*.{php}",
    "./${themePath}/**/*.{php}",
  ],
}

I use Laravel Mix for asset compilation, Tailwind is of course included in webpack.min.js file and it works well if I specify the file path in Tailwind's config - wildcards don't work however.

Is it possible?



Solution 1:[1]

The solution seems to be using some third-party library that can search for those files, like fast-glob (glob library for Node.js).

module.exports = {
    content: require('fast-glob').sync([
        './${themePath}/**/*.{php}',
    ]),
}

Works.

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1 Kristián Filo