Search code examples
.netdotless

Dotless recursive compiling


When using dotless for compiling less-files into min.css files. Is there any way to have the compiler check for all .less files in a certain filearea and then compile these into a single css file?


Solution

  • It ended up with me doing this in a controller that uses the less-dll to do the compiling myself. I then call the controller to get the fully functional, compiled css. Parts of my code below:

        protected void SetStringToLessFileFromAllWidgets()
        {
            var widgets = widgetInfoReader.GetWidgetsAvailable();
    
            foreach (var widget in widgets)
            {
                string cssLocation = widget.FullPath + "\\CSS\\Widget.less.css";
                AppendToStringBuilder(cssLocation);
            }
        }
    
        public string ParseAndReturnCSSFile()
        {
            cssString = Less.Parse(sb.ToString(), config);
            return cssString;
        }