Grunt 将每个目录中的所有 .less 编译为 .css

2024-04-14

因此,我已将站点设置为使用模块,其中每个模块都有自己的 .less 文件,需要将其编译为 .css。

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

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

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

我不想将每个模块单独添加到我的 grunt 文件中,有没有办法动态地执行此操作?


也可以看看:http://gruntjs.com/configuring-tasks#globbing-patterns 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'
        }]
      }
  }
  });
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)

Grunt 将每个目录中的所有 .less 编译为 .css 的相关文章

随机推荐