Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Grunt compile all .less to .css in each directory

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?

like image 327
Quinton Pike Avatar asked Jan 31 '26 06:01

Quinton Pike


1 Answers

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'
        }]
      }
  }
  });
like image 106
Bass Jobsen Avatar answered Feb 03 '26 08:02

Bass Jobsen



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!