Warning: file_get_contents(/data/phpspider/zhask/data//catemap/0/drupal/3.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
如何在Drupal 8中使用通配符在多个目录上运行grunt sass_Drupal_Gruntjs_Drupal 8_Grunt Sass Lint - Fatal编程技术网

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

如何在Drupal 8中使用通配符在多个目录上运行grunt sass,drupal,gruntjs,drupal-8,grunt-sass-lint,Drupal,Gruntjs,Drupal 8,Grunt Sass Lint,在我的Drupal 8项目中,我有自定义模块,其中每个主题中有两个目录SCS和css,因此结构如下: - modules - custom - my_module_1 - scss - css - my_module_2 - scss - css - themes - my_theme - Gruntfile.js 在我的Gruntfile.js中,我想告诉sass遍历每个自定义模块,并作为源在scss文件夹上运行

在我的Drupal 8项目中,我有自定义模块,其中每个主题中有两个目录SCS和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'
      }
    }
  }
正如您所看到的,它是冗余的,如何在一个通用命令中使它更干净(可能使用通配符,但我还没有弄清楚)


谢谢。

以防万一将来有人要找同样的答案

我最终用以下方法解决了这个问题:

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'
    }
  }
}

你有没有试过像:
“../../modules/custom/*/css/*.css:”../../modules/custom/*/scss/*.scss“,
我不太清楚,但我知道星号在grunt中是通配符。