{"action":"created","issue":{"url":"https://api.github.com/repos/gruntjs/grunt-contrib-sass/issues/178","labels_url":"https://api.github.com/repos/gruntjs/grunt-contrib-sass/issues/178/labels{/name}","comments_url":"https://api.github.com/repos/gruntjs/grunt-contrib-sass/issues/178/comments","events_url":"https://api.github.com/repos/gruntjs/grunt-contrib-sass/issues/178/events","html_url":"https://github.com/gruntjs/grunt-contrib-sass/issues/178","id":53236737,"number":178,"title":"Invoking sass once with all files to compile instead of invoking sass once per file to compile","user":{"login":"danfinnie","id":92105,"avatar_url":"https://avatars.githubusercontent.com/u/92105?v=3","gravatar_id":"","url":"https://api.github.com/users/danfinnie","html_url":"https://github.com/danfinnie","followers_url":"https://api.github.com/users/danfinnie/followers","following_url":"https://api.github.com/users/danfinnie/following{/other_user}","gists_url":"https://api.github.com/users/danfinnie/gists{/gist_id}","starred_url":"https://api.github.com/users/danfinnie/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/danfinnie/subscriptions","organizations_url":"https://api.github.com/users/danfinnie/orgs","repos_url":"https://api.github.com/users/danfinnie/repos","events_url":"https://api.github.com/users/danfinnie/events{/privacy}","received_events_url":"https://api.github.com/users/danfinnie/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":null,"milestone":null,"comments":4,"created_at":"2015-01-02T04:07:39Z","updated_at":"2015-01-03T15:25:41Z","closed_at":null,"body":"I was recently looking into using this plugin to run `sass --watch`.  I wanted to do this instead of using grunt-contrib-watch because `sass --watch` will use a cache to do incremental builds much faster than grunt-contrib-watch combined with this plugin (even with the update configuration option set to true).\r\n\r\nI realized that even though getting grunt-contrib-sass to send sass the --watch option is trivial, this strategy doesn't really work because sass --watch will block and grunt-contrib-sass invokes sass once per file to compile.  Why not send all the files to sass at once?  This would make --watch a usable option for development.  It also seems that minimizing the number of shell invocations and the number of times that the sass gem needs to boot would lead to better performance, but I haven't tested that hypothesis.\r\n\r\nI did some digging in Git to see if I could figure out why sass was invoked this way.  Here's what I found:\r\n\r\n1. In the initial commit, there's no looping over sass invocations, but I also didn't find how sass was invoked at all.\r\n1. Looping over `this.files` and invoking sass for each one was first introduced in 38320df, but this commit doesn't really explain why.\r\n1. The loop was removed in 7a68a29 as part of some changes about how grunt handles `this.files` vs. `this.file`.\r\n1. The subsequent commit, d6dfe52, brings the loop back and uses `this.files` again.  This was a result of gruntjs/grunt#606\r\n1. In commit f6bef05, `async.forEachLimit` instead of `async.forEachSeries` so that if you had multiple CPUs, they would all be put to work.  This was a result of gruntjs/grunt-contrib-sass#43.  What's interesting to me is that this PR states \"The sass command line parameters don't allow processing multiple files per run, which would presumably be even faster.\"  Maybe things have changed since that comment, or I'm misunderstanding what @altano is saying, but currently sass does let you specify multiple sources and destinations on the command line.\r\n1. In commit 14fdd13, `async.forEachLimit` was switched to `async.eachLimit`.  These are [synonymous functions](https://github.com/caolan/async/blob/3bcacd17fd3b7158247a4365b4d530ea5ff31da6/lib/async.js#L170), so this change was purely cosmetic.\r\n\r\n**tl;dr**: I don't understand why this plugin invokes sass once per element in `this.files` rather than joining `this.files` into one big argument list and invoking sass once.  I couldn't find the reason for this in the git history, is there a reason?  Or can it be changed to invoking sass once so that `sass --watch` works and fewer processeses are spawned in general?\r\n\r\n@jonathanpberger @geoffwa"},"comment":{"url":"https://api.github.com/repos/gruntjs/grunt-contrib-sass/issues/comments/68598178","html_url":"https://github.com/gruntjs/grunt-contrib-sass/issues/178#issuecomment-68598178","issue_url":"https://api.github.com/repos/gruntjs/grunt-contrib-sass/issues/178","id":68598178,"user":{"login":"danfinnie","id":92105,"avatar_url":"https://avatars.githubusercontent.com/u/92105?v=3","gravatar_id":"","url":"https://api.github.com/users/danfinnie","html_url":"https://github.com/danfinnie","followers_url":"https://api.github.com/users/danfinnie/followers","following_url":"https://api.github.com/users/danfinnie/following{/other_user}","gists_url":"https://api.github.com/users/danfinnie/gists{/gist_id}","starred_url":"https://api.github.com/users/danfinnie/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/danfinnie/subscriptions","organizations_url":"https://api.github.com/users/danfinnie/orgs","repos_url":"https://api.github.com/users/danfinnie/repos","events_url":"https://api.github.com/users/danfinnie/events{/privacy}","received_events_url":"https://api.github.com/users/danfinnie/received_events","type":"User","site_admin":false},"created_at":"2015-01-03T15:25:41Z","updated_at":"2015-01-03T15:25:41Z","body":"Awesome! I'll put together a pull request soon based on this for you to\r\ntake a peek at.\r\nOn Jan 3, 2015 10:02 AM, \"Sindre Sorhus\" <notifications@github.com> wrote:\r\n\r\n> @geoffwa <https://github.com/geoffwa> I did not know about that. PR\r\n> welcome as long as it doesn't break anything.\r\n>\r\n> —\r\n> Reply to this email directly or view it on GitHub\r\n> <https://github.com/gruntjs/grunt-contrib-sass/issues/178#issuecomment-68597481>\r\n> .\r\n>"}}