callumlocke / node-ruby-sass

1 stars 1 forks source link

Couple notes from GRS #5

Open robwierzbowski opened 8 years ago

robwierzbowski commented 8 years ago

Not sure if you're still working on this plugin, but I thought it might be helpful to share notes.

Speed: current releases of gulp-ruby-sass don't have caching. The 2.0 branch that I'm working on today will. That should speed things up considerably, but needs a little extra input from the user when compiling directories.

Ruby Bindings: One of the issues I'm running into is parsing the CLI output. Unfortunately the Sass CLI sends output in unstructured chunks, with exit code differences between file and directory compilation. See https://github.com/sass/sass/issues/1715 for more info.

Nex3 advised me to use the Ruby gem for better parsing of messages, but of course I would have to write a Ruby app with bindings exposed to node. It seems like you've done something like that here. How'd it work out?

callumlocke commented 8 years ago

It worked OK but the truth is I haven't looked at it for a long time because libsass became good enough for me to stop using Ruby Sass.

I was trying to make a Ruby 'server' that could stay running as a single child process of Node (and be automatically killed when Node exits), being called for repeated renders of Sass files, therefore cutting out the Ruby spin-up penalty after the first render (and maybe even keep the same Sass instance in memory for caching partials between renders, but I don't think I made it that far). I just about got it working and used it in a couple of projects. What inspired me to do this was that Rails seemed insanely fast to re-render after a small change to a single partial, much faster than GRS, so I thought maybe it was about keeping Ruby up...

I used dnode for communicating between the processes because it was the only thing that was fast and that I could follow the docs of. I know what I'm doing with Node, but my Ruby experience (outside Rails) is very limited and I remember feeling like I was just prodding code around till something ran. Dnode seemed good though.

Want to take over this repo? I think it's definitely a good idea to do all the Node-Ruby binding logic in one repo and just export a clean JS API that you can use from GRS or anywhere else. Whether you agree with the 'keep Ruby running between renders' idea is another matter though.