Commit 604ccf58 by Michael Mifsud

Merge pull request #629 from xzyfer/feat/better-watcher-compilation-targets

Use sass-graph for accurate sass watching
parents c9e3eaad fa13e98f
......@@ -5,6 +5,7 @@ var Emitter = require('events').EventEmitter,
meow = require('meow'),
replaceExt = require('replace-ext'),
stdin = require('get-stdin'),
grapher = require('sass-graph'),
render = require('../lib/render');
/**
......@@ -173,10 +174,20 @@ function watch(options, emitter) {
gaze.add(dir);
gaze.on('error', emitter.emit.bind(emitter, 'error'));
var graph = grapher.parseDir(options.src, { loadPaths: options.includePath });
gaze.on('changed', function(file) {
options = getOptions([file], options);
emitter.emit('warn', '=> changed: ' + file);
render(options, emitter);
var files = [file];
graph.visitAncestors(file, function(parent) {
files.push(parent);
});
files.forEach(function(file) {
if (path.basename(file)[0] === '_') return;
options = getOptions([path.resolve(file)], options);
emitter.emit('warn', '=> changed: ' + file);
render(options, emitter);
});
});
}
......
......@@ -55,6 +55,7 @@
"object-assign": "^2.0.0",
"replace-ext": "0.0.1",
"request": "^2.48.0",
"sass-graph": "^1.0.1",
"shelljs": "^0.3.0"
},
"devDependencies": {
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment