I have read this tutorial for working with Less in Asp.Net MVC5.
To integrate LESS in ASP.NET MVC, I download and install the dotless NuGet package.
And then added this bundle:
var lessBundle = new Bundle("~/Less").Include("~/Content/Less/*.less");
lessBundle.Transforms.Add(new LessTransform());
lessBundle.Transforms.Add(new CssMinify());
bundles.Add(lessBundle);
Here is the LessTransform:
public class LessTransform : IBundleTransform
{
public void Process(BundleContext context, BundleResponse response)
{
response.Content = dotless.Core.Less.Parse(response.Content);
response.ContentType = "text/css";
}
}
So far so good. Everything works as it is expected.
Here is the part from my .less file:
@CustomMessageBackgroundColor: #65B6A7;
div.custom-dialog {
...
background: @CustomMessageBackgroundColor;
}
Now, I want to change the value of this variable from .js file dynamically:
less.modifyVars({ '@CustomMessageBackgroundColor': 'blue' });
less.refreshStyles();
But, this is not working. I have read all SO questions and as I understand this must work.
Thanks.