0

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.

Ian Grainger
  • 5,148
  • 3
  • 46
  • 72

1 Answers1

2

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.

AlexCuse
  • 18,008
  • 5
  • 42
  • 51
  • This could be it as I think it worked on another machine, and the visual studio versions are different (back in 2010 on the one that's not working)... I'll check now, thanks! – Ian Grainger Nov 27 '13 at 09:15
  • OK - you were right - but there was another problem when I stopped using the test.less, and started including my .css file - this was left as a CSS include and using .ProcessIncludes() made no difference - I changed the extension to .css.less and it worked. I can start a new question for that issue? – Ian Grainger Nov 27 '13 at 11:27
  • A new question probably makes sense. I think we have a way to get this working, will hopefully get a chance to research by the time you've posted it. – AlexCuse Nov 27 '13 at 19:32