Sass is a language that compiles into CSS. It supports may useful features, such as nesting, variables, imports, inheritance, mixins and more.
In large projects with many Sass files, constantly compiling all the Sass files to CSS can be expensive during dev time.
Your goal: To create a 'Smart Sass' node module which, when run, will help to optimize the Sass compilation by deciding which files need to be compiled. How can the compilation be optimized? If compilation of a sass a file would have the same css output as before, then it does not need to be compiled again.
The module should receive an array of source directories/patterns as input (i.e. using glob, minimatch or the like), representing where the Sass files are located, and a target directory root which represents where the css files are written to using the same patterns applied to the target root directory.
Your output should be an array of the files which need to be compiled.
###Guidelines:
- Although you do not need to actually compile the files, you should carefully read the features supported by Sass. There may be features you need to specifically account for when deciding which files need compilation.
- The module can have dependencies. Use of existing utilities and npm packages is encouraged (and likely necessary for a good solution). That said, the module should be able to be run by itself without being dependent on a task runner such as grunt to run it.
- You can write the module either as a synchronous task or an asynchronous one. The choice is yours.
- If it's synchronous, it should return an array of the filepaths which need to be compiled by Sass.
- If it's asynchronous, it should also accept a callback, which will be called upon completion with an array of the filepaths as the argument to the callback.
- Your submission should also wrap the module and log the result to the system console.
- Bonus points: write it TDD style with good test coverage.
A synchronous version of the exported module should have the following signature:
function smartSass(sourcePatterns, targetDirectoryRoot){
var filesWhichNeedSass = [];
// ..
// ..
return filesWhichNeedSass;
}
An asyncronous version of the exported module should have the following signature:
function smartSass(sourcePatterns, targetDirectoryRoot, callback){
// var filesWhichNeedSass = [];
// ..
// ..
// when done:
// callback(err, filesWhichNeedSass);
}
The callback should support the node-style callbacks in order to support error reporting.
Please also submit a partial solution if you have not completed it. A partial solution is better than none at all.
###Send your solution as a zip file to [email protected]