微信公众号搜"智元新知"关注
微信扫一扫可直接关注哦!

PurgeCSS:如何定义所有子目录的路径?

如何解决PurgeCSS:如何定义所有子目录的路径?

基本的postcss.config.js看起来像这样

const purgecss = require('@fullhuman/postcss-purgecss')

module.exports = {
  plugins: [
    purgecss({
      content: ['./**/*.html']
    })
  ]
}

我遇到一种情况,需要定义带有嵌套子目录的文件夹的路径。我发现的唯一explanation是这个:

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`],

...但是我要有所不同:如何定义文件夹及其所有子目录(及其子目录等)的路径?

something

glob.glob('**/*.txt',recursive=True):匹配当前目录和所有子目录中所有以'.txt'结尾的文件

如何在PostCSS / PurgeCSS中设置选项recursive=True

解决方法

我的 postcss.config.js 看起来像这样:

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',],

版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 dio@foxmail.com 举报,一经查实,本站将立刻删除。