如何在 Drupal 8 中使用通配符在多个目录上 运行 g运行t sass

How to run grunt sass on several directories with wildcard in Drupal 8

在我的 Drupal 8 项目中,我有自定义模块,在每个主题中我有两个目录 scss 和 css,因此结构如下:

- modules
  - custom
    - my_module_1
      - scss
      - css
    - my_module_2
      - scss
      - css
- themes
  - my_theme
    - Gruntfile.js

在我的 Gruntfile.js 中,我想告诉 sass 遍历每个自定义模块和 运行 在 scss 文件夹上作为源和 css 文件夹应该是目的地。

到目前为止,我有如下任务:

  sass: {
    prod:{
      options: {
        sourceMap: false,
        outputStyle: 'compressed',
        includePaths: ['scss']
      },
      files: {
        '../../modules/custom/my_module_1/css/file1.css': '../../modules/custom/my_module_1/scss/file1.scss',
        '../../modules/custom/my_module_1/css/file2.css': '../../modules/custom/my_module_1/scss/file2.scss',
        '../../modules/custom/my_module_2/css/file1.css': '../../modules/custom/my_module_2/scss/file1.scss'
      }
    }
  }

如您所见,它是多余的,如何在一个通用命令中使其更清晰(可能使用通配符,但我还无法弄清楚)

谢谢。

以防万一以后有人在寻找相同的答案。

我最终用 expand 解决了这个问题,方法如下:

sass: {
  prod:{
    options: {
      sourceMap: false,
      outputStyle: 'compressed',
      includePaths: ['scss']
    },
    files: {
      expand: true,
      src: ['../../modules/custom/*/scss/*.scss'],
      dest: '/css',
      rename: function(dest, src){
        var fname = src.substring(src.lastIndexOf('/'),src.lastIndexOf('.'));
        return src.substring(0, src.lastIndexOf('/scss')) + dest + fname + '.css';
      },
      ext: '.css'
    }
  }
}