在每个目录中将所有的.less文件编译成.css文件。

3
我已经设置了我的网站以使用模块,每个模块都有自己的.less文件需要编译成.css文件。
文件夹结构:
/common/modules/{module-name}/style.less
我需要将所有的style.less文件都转换成相同目录下的style.css文件。例如:
/common/modules/clock/style.less 需要被编译成 /common/modules/clock/style.css
我不想在grunt文件中单独添加每个模块,请问是否有一种动态的方式可以实现这一点?
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'
        }]
      }
  }
  });

网页内容由stack overflow 提供, 点击上面的
可以查看英文原文,
原文链接