
Security News
NVD Concedes Inability to Keep Pace with Surging CVE Disclosures in 2025
Security experts warn that recent classification changes obscure the true scope of the NVD backlog as CVE volume hits all-time highs.
@dietechniker/gulp-sass-dependency-tracker
Advanced tools
A NodeJS gulp package to optimize sass compilation - only compile what you actually changed.
A NodeJS module for keeping things easy in sass tasks for Gulp.
This gulp plugin filters the file stream to include only scss files that have to be recompiled.
Also features automatic dependency tracking based on the same stream.
Best fitted for gulp watch tasks where partial rebuilds are desirable.
Firstly, here's a quick example:
// Sass-Dependency-Tracker for partial recompilation
const SassDepTracker = require('gulp-sass-dependency-tracker');
const sassDepTracker = new SassDepTracker();
const fileGlob = 'resources/sass/**/*.scss';
gulp.task('sass', function () {
gulp.src(fileGlob)
.pipe(sassDepTracker.filter())
.pipe(gulpPrependAppend.prependText(`@import 'some-mandatory-import-prepended';`))
.pipe(sassDepTracker.inspect(sassOptions))
.pipe(sassDepTracker.logFiles())
.pipe(sass(sassOptions).on('error', sass.logError))
.pipe(gulp.dest('.'))
});
gulp.task('sass:watch', function () {
let watcher = gulp.watch(fileGlob, 'sass');
watcher.on('unlink', file => {
log.info(`File deleted: ${file.path}`);
sassDepTracker.queueRebuild(file);
});
watcher.on('add', file => {
log.info(`File added: ${file.path}`);
});
watcher.on('change', file => {
log.info(`File changed: ${file.path}`);
sassDepTracker.queueRebuild(file);
});
});
As you can see, we have four main things to register in order to get things flying:
DependencyTracker#filter()
DependencyTracker#logFiles()
if you want a notification about whats left in the stream.DependencyTracker#inspect(<sassOptions>)
Note: On the first run all files in the stream are marked dirty as none of them have been analyzed yet.
filter()
The filter function is responsible for keeping only the files in the stream which need to be recompiled.
When a file change is reported (#queueRebuild
), the file and all its depending files will be marked for recompile.
inspect(<sassOptions>)
When the stream is piped through this function, the plugin reads @import
statements from the files contents.
This information is used to determine which files depend on which.
That also means, that any dependencies not in the stream cannot be tracked. (Little hint at the bottom)
queueRebuild(<file>)
on watchersWhen a file has been changed, it needs to be marked for recompilation with its depending files.
This method does exactly that.
It is recommended that file
is a Vinyl file but an absolute normalized path should work too.
logFiles
Just a convenience function that logs out the absolute file paths from the stream so you know what will be compiled.
In normal use cases, the helper can detect all dependencies through the inspect
function.
That means that any dynamically injected imports will have to be added before filter()
is called.
If you need to have dependencies tracked which are not/never included in the stream, you may manually register them.
Take a look at #reportImport(<match>, <file>, <sassOptions>)
for that purpose.
There are two kinds of options:
includePaths
from the options so we can properly resolve the imports. {
debug: false // Whether or not to provide debug log message (e.g. from the dependency detection)
}
FAQs
A NodeJS gulp package to optimize sass compilation - only compile what you actually changed.
We found that @dietechniker/gulp-sass-dependency-tracker demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Security News
Security experts warn that recent classification changes obscure the true scope of the NVD backlog as CVE volume hits all-time highs.
Security Fundamentals
Attackers use obfuscation to hide malware in open source packages. Learn how to spot these techniques across npm, PyPI, Maven, and more.
Security News
Join Socket for exclusive networking events, rooftop gatherings, and one-on-one meetings during BSidesSF and RSA 2025 in San Francisco.