mike-ward / Nancy.Pile

A Super Simple Asset Bundler for NancyFx
MIT License
16 stars 4 forks source link

Compiling CoffeeScript and Less #2

Open Crisfole opened 10 years ago

Crisfole commented 10 years ago

I use the following to help compile coffeescript and less. (I also have a static resource provider, but that won't work with your bundling setup, so I present the rest here).

The files depend on MsieJavascriptEngine and dotLess, as well as an embedded resource named Coffeescript containing an up-to-date coffeescript.js file.

https://gist.github.com/Crisfole/39fab8875764f6a0187b

The code should be self-explanatory. Let me know if you're interested or want help incorporating it.

mike-ward commented 10 years ago

Hey, thanks. I'll have a look.

Can Coffee Script and DotLess files be compiled individually or do they have to be concated first?

Crisfole commented 10 years ago

The code I linked to is purely for individually compiling them...I haven't quite worked out how to concatenate them after compiling...I was hoping your code might help me solve that issue :)

mike-ward commented 10 years ago

That's not what I meant. Does the LESS compiler need to see all .less files to sucesssfully compile them or can they be built serially? Sounds like you're building them serially but then how would named constants get processed. I can read the docs and figure it out.I can handling the concat. :)

Crisfole commented 10 years ago

The less compiler reads the @import statements and searches the file-system relative to the file being built or referenced. I hack into that a little bit to detect changes to dependent files and determine if the file needs rebuilding.

mike-ward commented 10 years ago

OK, I added the less and coffee stuff. Clone the repository and have a look to see if it's what you were expecting.

Crisfole commented 10 years ago

Wow, that was fast. I'm impressed. I hadn't heard of Jint when I wrote this stuff, it looks slick. I'll take a peek :) :+1:

Crisfole commented 10 years ago

Looking at the code I don't see anything that watches Less imports for changes, is that hiding somewhere I'm not noticing?

mike-ward commented 10 years ago

The filewatcher stuff at the bottom of bundle.cs handles that.

Crisfole commented 10 years ago

Slick. I hadn't thought of that. I'll get a chance to try using it today, I'll let you know how it goes.

mike-ward commented 10 years ago

Crisfole: Any feedback?

Crisfole commented 10 years ago

Sorry, got caught up in other unrelated work, it might have to wait a bit. On the other hand, if it works....