Wednesday, March 17, 2010

Style sheet compression and .less add-in...updated with source



6/2/2010 Update - Project enhanced and now on codeplex!   http://chirpy.codeplex.com/

Design time minification and .net less for style sheets.
Read my previous post on this subject.  






Known Issues
It has been reported that this does not work in 'web site project'.  I do not  use those anymore, not since they brought back our 'web application project'.  If anyone wants to try and make it work, the code is attached.



Source Code
I finally got around to updating this to the latest version of the less engine and api.   In addition, I had been promising source code for a while now.

Click to download

Shout it
kick it on DotNetKicks.com

8 comments:

Unknown said...

Thanks for updating this Wayne, great work. Just a quick question though - am I correct that :nth-child(n) gets filtered out?

:nth-child(odd) and :nth-child(even) seem to work perfectly, but when I put a number in there the LESS compiler seems to filter everything out...?

Hope you can help me out. Thanks!

Wayne Brantley said...

@pim.derks:
unsure - ask that in the .less google group.

Anonymous said...

Hi

Thanks for this. works great.

P.S. Could you change your blog to include the date a post/comment was made? just displaying the time against a post/comment is not very helpful

Wayne Brantley said...

done.

Kamran A said...

Would you be able to post this add-in on CodePlex? That way maybe some of us can jump on the bandwagon and add patches. :)

I use the Publish feature in VS 2010 because of web.config transforms and File System publishing. I'm worried that the .less files will be published too... obviously don't want that; just want the generated CSS files.

No idea how to patch it to do that, but at least a CodePlex project would have SVN and track source code changes/issues.

Matt said...

Wayne, great update! Do you have plans to support VS 2010?

Eli Gassert said...

I made a tweak to TransformLessToCss that allows for @imports to work properly. I have all my custom variables and functions in one less file and import it into my other less files. This wasn't working in the current addin, so I made a quick tweak to fix it by setting the CurrentWorkingDirectory to the directory of the current LESS file... seems to work like a charm. Also, By changing the addin's version to 10.0 VS2010 can use it no problem. Here's the code:

private string TransformLessToCss(string fullFileName)
{
var config = new dotless.Core.configuration.DotlessConfiguration { MinifyOutput = true };

// Transform file content from less to css
ILessEngine less = new EngineFactory().GetEngine(config);
LessSourceObject lso=new LessSourceObject();
lso.Key = fullFileName;
using (StreamReader rdr = File.OpenText(fullFileName))
{
lso.Content=rdr.ReadToEnd();
}

var current = Directory.GetCurrentDirectory();
Directory.SetCurrentDirectory(new FileInfo(fullFileName).DirectoryName);

var ret = less.TransformToCss(lso);

Directory.SetCurrentDirectory(current);

return ret;
//return less.TransformToCss(fullFileName);
}

zazelfabin said...

It quickly as} skilled a “coal rush” when coal was used as a serious nationwide energy source during the Nineteen Seventies to 1980s. The Kangwon province had skilled devastating economic downturns since coal was replaced by gasoline and oil in the 90s. The Korean authorities tried to introduce quantity of} alternate options to revitalize the native financial system, however the neighborhood repeatedly and vigorously requested a home casino, and it became licensed in December 1995. According to the Korea Center on Gambling Problems, which was established by the government in 2012, the prevalence of gambling dependancy is two-to-three occasions larger in Korea than in other major international locations. While it’s unclear how these statistics are compiled, the notion that Koreans are uniquely susceptible to gambling dependancy is a widespread social concept that informs the legal guidelines surrounding the issue. The legal professional pointed out the prevalence of reviews in the 카지노게임 Korean news media highlighting folks whose lives have been broken by gambling dependancy.