3

所以我设置了我的站点以使用模块,其中每个模块都有自己的 .less 文件,需要编译成 .css。

文件夹结构: /common/modules/{module-name}/style.less

我需要将所有 style.less 文件转换为同一目录中的 style.css 文件。例如:

/common/modules/clock/style.less将需要编译为/common/modules/clock/style.css

我不想将每个模块单独添加到我的 grunt 文件中,有没有办法动态地做到这一点?

4

1 回答 1

4

另请参阅: http: //gruntjs.com/configuring-tasks#globbing-patterns

您可以定义以下任务:

  grunt.initConfig({
    less: {
      compileCore: {
        options: {
          strictMath: true
        },
        files: [{
          expand: true,
          src: ['/common/modules/**/style.less'], 
          ext: '.css',
          extDot: 'first'
        }]
      }
  }
  });
于 2014-10-09T23:57:25.503 回答