lesssquishit

Squishit.Less doesn't do anything


I've used package manager to install Squishit.Less 0.9.3, and I have two files

  1. style.less - @import "test.less";
  2. test.less - body{background-color: pink;}.

In my page I have:

<%= Bundle.Css().Add("~/less/style.less").ForceRelease().Render("~/less/combined.css") %>

But the output I get is: @import"test.less"; - the less processor hasn't tried to get the import for some reason?

I've tried ProcessImports but that made no difference.


Solution

  • I just verified in a sample project that it works correctly.

    You should NOT need to call ProcessImports - the less preprocessor should do this automatically. ProcessImports is for @imports in standard CSS, which aren't processed by default.

    I suspect what happened is that NuGet didn't add the file that registers the preprocessor. As a result the less preprocessor is never called. If you look under App_Start you should see a file called SquishItLess.cs with the following contents:

    [assembly: WebActivator.PreApplicationStartMethod(typeof(MyProject.App_Start.SquishItLess), "Start")]
    
    namespace MyProject.App_Start
    {
        using SquishIt.Framework;
        using SquishIt.Less;
    
        public class SquishItLess
        {
            public static void Start()
            {
                Bundle.RegisterStylePreprocessor(new LessPreprocessor());
            }
        }
    }
    

    If this file is missing, you can either add it or add the Bundle.RegisterStylePreprocessor line in your Global.asax.cs' Application_Start method.

    If you're installing to a VB project this is a known issue (https://github.com/jetheredge/SquishIt/issues/232) and will be addressed when the plug is pulled on .net 3.5 support.