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, ...@@ -5,6 +5,7 @@ var Emitter = require('events').EventEmitter,
meow = require('meow'), meow = require('meow'),
replaceExt = require('replace-ext'), replaceExt = require('replace-ext'),
stdin = require('get-stdin'), stdin = require('get-stdin'),
grapher = require('sass-graph'),
render = require('../lib/render'); render = require('../lib/render');
/** /**
...@@ -173,11 +174,21 @@ function watch(options, emitter) { ...@@ -173,11 +174,21 @@ function watch(options, emitter) {
gaze.add(dir); gaze.add(dir);
gaze.on('error', emitter.emit.bind(emitter, 'error')); gaze.on('error', emitter.emit.bind(emitter, 'error'));
var graph = grapher.parseDir(options.src, { loadPaths: options.includePath });
gaze.on('changed', function(file) { gaze.on('changed', function(file) {
options = getOptions([file], options); 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); emitter.emit('warn', '=> changed: ' + file);
render(options, emitter); render(options, emitter);
}); });
});
} }
/** /**
......
...@@ -55,6 +55,7 @@ ...@@ -55,6 +55,7 @@
"object-assign": "^2.0.0", "object-assign": "^2.0.0",
"replace-ext": "0.0.1", "replace-ext": "0.0.1",
"request": "^2.48.0", "request": "^2.48.0",
"sass-graph": "^1.0.1",
"shelljs": "^0.3.0" "shelljs": "^0.3.0"
}, },
"devDependencies": { "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