【问题标题】:PurgeCSS: How to define path to all subdirectories?PurgeCSS:如何定义所有子目录的路径?
【发布时间】:2021-02-11 01:37:55
【问题描述】:

基本的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 选项?

【问题讨论】:

  • 您找到答案了吗?我也有同样的情况
  • 我发布了一个答案。希望这会有所帮助。

标签: glob postcss css-purge


【解决方案1】:

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

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 2014-12-30
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2016-01-17
    • 2021-04-13
    • 2013-09-14
    相关资源
    最近更新 更多