Less variables are not replaced when compiling and error occurs

0

I am using less for the first time and I am having some problems. It's a MVC project and I'm using dotless and System.Web.Optimization.Less .

I have registered a bundle to include all my files less and return a single minimized file to the browser.

         bundles.Add(new StyleBundle("~/Content/Less").Include(
                 "~/Styles/Layout/Colores.less", 
                 "~/Styles/Layout/Global.less"));

As you can see, I am including a color file that contains the variables that define them, so that they can be used later in the rest of the project's less files. I also include a file to define the global style of the application that uses these variables ..

But when I go with the browser to the page, the less generated file contains the following error:

    /* Minification failed. Returning unminified contents.
      (54,12): run-time error CSS1036: Expected expression, found '@colorBlanco'
      (83,15): run-time error CSS1035: Expected colon, found ';'
    */

My Color.less file has the following content:

    @colorGris:         #808080;
    @colorBlanco:       #FFFFFF;


    /*Bordes*/
    @colorBordeInput:       #b1b1b1;
    @colorBordeContainer:   #E9EAEC;


    /*Sombras*/
    @colorSombraInput:      #a5a5a5;
    @colorSombraFocusInput: #81005D;



    /*******************
      ****  Layout ****
     *******************/
        /* userDataLine */
        @colorNombreUsuario: #700056;

What is the problem? If I see the file global.css file that is automatically generated in Visual Studio if I see that the variable has been changed by its corresponding value, for example:

#whereIAm #titleAndPath span {
  color: #ffffff;
}

Thank you!

    
asked by Neoff 27.09.2017 в 10:49
source

2 answers

0

The StyleBundle performs the minification of the css files but does not compile the less files.

If you are already generating, as you mention, the css files from the development environment itself are the ones that you should add to the bundle.

    
answered by 27.09.2017 в 11:22
0

Ok, looking at the ASP.NET website I found the answer. Indeed, the problem was that the previous compilation was not being done. I assumed it was done automatically, but it seems that you have to create a class that implements IBundleTransform and call explicitly for the compilation to take place.

It is very well explained in this link: link

Thanks Asier, your answer has put me on the right path to end up finding the solution !!!

    
answered by 27.09.2017 в 13:07