The basic postcss.config.js looks like this
const purgecss = require('@fullhuman/postcss-purgecss')
module.exports = {
plugins: [
purgecss({
content: ['./**/*.html']
})
]
}
I have a situation where I need to define the path to a folder with nested subdirectories. The only explanation I found was this one:
content: [
// keep only those that you need
'**/*.html' // will look inside any folder for an .html file
'!(bar)/**/*.html' // will look inside any folder that is not 'bar'
'!({bar,foo})/**/*.html' // will look inside any folder that is nor 'bar' nor 'foo'
'!(bar-*)/**/*.html' // will look inside any folder that does not start with 'bar-'
],
css: [`**/*.css`],
...but I want something different: How to define the path to a folder and all his subdirectories (and their subdirectories and so on)?
There is something like
glob.glob('**/*.txt',recursive=True)
: matches all files ending in '.txt' in the current directory and in all subdirectories
How to set the option recursive=True
in PostCSS/PurgeCSS?
My postcss.config.js
looks like this:
const themeDir = __dirname + '/../../';
const purgecss = require('@fullhuman/postcss-purgecss')({
// Specify the paths to all of the template files in your project
content: [
themeDir + 'layouts/**/*.html',
themeDir + 'content/**/*.html',
'layouts/**/*.html',
'content/**/*.html',
// Specify path to own javascript
themeDir + 'assets/js/**/*.js',
],