Update: Chirpy has new features, and you can download the source code from Codeplex. So, once you’re finished reading this, head on over to this post.
You’d think minification would be a lot cooler and easier. Like, say, Honey, I Shrunk The Kids. But, alas.
Wayne Brantley released a nice DotLess translator a couple months ago. Before that, Phil Haack created a nice T4 template for mashing and minifying DotLess, Css, and Js files. Today, in the spirit of my Zippy Series, I’ve enhanced (or deprecated [on?]) Wayne’s creation with a couple of new features, which I’ll discuss briefly below.
Before you get too frisky, make sure to download Chirpy Zippy here.
Also, if you’re new to working with Visual Studio AddIns, or if you just need a little help installing Chirpy Zippy, feel free to check out the instructions page. It shouldn’t take you more than a couple of minutes to set Zippy up.
And now, drum roll, shock and awe, get naked please, or sit there, and let’s just get right down to business. The business: for starters, assuming we’ve already added Chirpy Zippy to our AddIns folder, let’s put it to good use. Add a new javascript file to your project. We’ll call it hello.chirp.js. Adding the “.chirp.js” suffix to our filename is Zippy’s cue to look after the file. Quickly, you’ll notice that our new javascript file has a “codebehind” file. Ah, snap:
Now, whenever we make modifications to our javascript file, the “min.js” version of the file will–you guessed it–be a minified file that we can use however we see fit. If you’re wondering, Zippy uses the YUI Compressor to do his compressing.
Zippy also fondles stylesheets. For example, create a stylesheet called “hello.chirp.css,” and (..if you can’t see what’s coming here, I fear for your children) voila:
Zippy also handles .less files. For example, add “howdy.chirp.less” to your project, and you’ll get both a minified and a non-minified css file. Not too shabby:
What about mashing? Add as many .chirp.config files to your project as you want. In the config file, you can specify file groups. You can also specify which files get minified:
<root>
<FileGroup Name="group1.js">
<File Path="jquery-1.4.1.min.js" Minify="false" />
<File Path="jquery.json.js" />
<File Path="MicrosoftAjax.js" />
</FileGroup>
<FileGroup Name="group2.js">
<File Path="jquery-1.4.1.min.js" Minify="false" />
<File Path="jquery.json.js" />
</FileGroup>
<FileGroup Name="group1.css">
<File Path="../Styles/jquery-ui-1.8.custom.css" />
<File Path="../Styles/colorbox.css" />
<File Path="howdy.chirp.less" />
</FileGroup>
</root>
Saving the above config file results in the following outputted files:
Think that’s it? Nope. If you’re super-lazy, you can mash together all of the files in a folder:
<root>
<FileGroup Name="main.scripts.js">
<Folder Path="/" Type="*.min.js" Minify="false"/>
<File Path="MicrosoftAjax.js" />
</FileGroup>
</root>
—
Now For The Kind Of Warning You Put On Things That Could Really Hurt People
This project isn’t perfect, but it works. Yes, it works well enough that I’m not completely ashamed of it.So, that said, if there’s any amount of interest in extending this project, or increasing its stability, or destroying it, maybe Wayne could be enticed into helping me throw together a code project (eh, eh?) or something. Some way for others to fix things for me? I have beers to drink. Please? Help?
Anyways. It’s late. It’s Friday. And I’m done fiddling.
Must. Stop. Ignoring. Family. And. Wife.
Read More
You can leave a response, or trackback from your own site.
7 Responses to “Chirp Chirp: Visual Studio Add-In for DotLess, Js, and Css Files”
Leave a Reply






I don’t know if it’s a bug or a feature but your nasty chippy removes css import commands like: “@import url(“jquery.ui.core.css”);
@import url(“jquery.ui.button.css”);
@import url(“jquery.ui.slider.css”);”
Solution:
1. It should either put it into the generated file
or
2. Should grab the file to be imported and merge it into the file ( would be cool.. )
cheers,
Hey David,
Looks like a problem I inherited from the initial AddIn. On Wayne’s blog, Eli Gassert mentions a fix, which I added to the project, and hopefully everything should work now?
I tested imports on my end, and all seems well. Let me know if you have any issues.
Cheers,
Evan
In visual studio 2010 error message :
Exception was thrown.
System.NullReferenceException: object reference not set to an insance of an ojbect.
at zippy.chirp.manager.vsprojectItemManager.process()
at zippy.chirp.manager.vsprojectItemManager.dispose()
at zippy.chirp.connect.genrateMiniJsFormJs(projextItem projectItem)
Hey Francis,
Can you get _any_ js files to minify in VS2010? I think this might be a VS2010 vs VS2008 issue, or it might be that the file you’re trying to minify is crapping out. Either way, I’d like to get it fixed.
Cheers,
E
You are right – would be a good codeplex project. However, I saw recently the dotless folks were considering (or did) putting my add-in into their official distribution. Either way, good stuff – feel free to contact me.
FYI to everyone–
Thanks to some help from some folks out in the wilderness (particularly Francis), I’ll be putting a much cleaner (VS10 and VS08 friendly) version of this project up on Codeplex in the next couple of days. I’ve been surprised by the amount of interest, and I’m looking forward to your help in ironing out the details of this little VS AddIn.
Cheers,
Evan
[...] Zippy? New to Zippy? Check out Zippy 101 before feasting your virgin eyes on the mind-blowing content expunged below this delicate [...]