Skip to content
This repository was archived by the owner on Jul 24, 2024. It is now read-only.

Commit 604ccf5

Browse files
committed
Merge pull request #629 from xzyfer/feat/better-watcher-compilation-targets
Use sass-graph for accurate sass watching
2 parents c9e3eaa + fa13e98 commit 604ccf5

File tree

2 files changed

+15
-3
lines changed

2 files changed

+15
-3
lines changed

bin/node-sass

Lines changed: 14 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@ var Emitter = require('events').EventEmitter,
55
meow = require('meow'),
66
replaceExt = require('replace-ext'),
77
stdin = require('get-stdin'),
8+
grapher = require('sass-graph'),
89
render = require('../lib/render');
910

1011
/**
@@ -173,10 +174,20 @@ function watch(options, emitter) {
173174
gaze.add(dir);
174175
gaze.on('error', emitter.emit.bind(emitter, 'error'));
175176

177+
var graph = grapher.parseDir(options.src, { loadPaths: options.includePath });
178+
176179
gaze.on('changed', function(file) {
177-
options = getOptions([file], options);
178-
emitter.emit('warn', '=> changed: ' + file);
179-
render(options, emitter);
180+
var files = [file];
181+
graph.visitAncestors(file, function(parent) {
182+
files.push(parent);
183+
});
184+
185+
files.forEach(function(file) {
186+
if (path.basename(file)[0] === '_') return;
187+
options = getOptions([path.resolve(file)], options);
188+
emitter.emit('warn', '=> changed: ' + file);
189+
render(options, emitter);
190+
});
180191
});
181192
}
182193

package.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -55,6 +55,7 @@
5555
"object-assign": "^2.0.0",
5656
"replace-ext": "0.0.1",
5757
"request": "^2.48.0",
58+
"sass-graph": "^1.0.1",
5859
"shelljs": "^0.3.0"
5960
},
6061
"devDependencies": {

0 commit comments

Comments
 (0)