Grunt compile all .less to .css in each directory

馋奶兔 提交于 2020-01-04 14:16:40

问题


So I have setup my site to use modules, in which each module has it's own .less file which needs to be compiled into .css.

Folder Structure: /common/modules/{module-name}/style.less

I need all the style.less files to be converted into style.css files in the same directory. For example:

/common/modules/clock/style.less would need to be compiled to /common/modules/clock/style.css

I don't want to have to add each of the modules individually to my grunt file, is there a way to do this dynamically?


回答1:


See also: http://gruntjs.com/configuring-tasks#globbing-patterns

You can define the following task:

  grunt.initConfig({
    less: {
      compileCore: {
        options: {
          strictMath: true
        },
        files: [{
          expand: true,
          src: ['/common/modules/**/style.less'], 
          ext: '.css',
          extDot: 'first'
        }]
      }
  }
  });


来源:https://stackoverflow.com/questions/26106254/grunt-compile-all-less-to-css-in-each-directory

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!