@mapbox/batfish
Version:
The React-powered static-site generator you didn't know you wanted
31 lines (23 loc) • 760 B
JavaScript
//
;
const _ = require('lodash');
const chokidar = require('chokidar');
const compileStylesheets = require('./compile-stylesheets');
function watchCss(
batfishConfig ,
options
) {
if (_.isEmpty(batfishConfig.stylesheets)) return;
const cssWatcher = chokidar.watch(batfishConfig.stylesheets);
cssWatcher.on('change', () => {
compileStylesheets(batfishConfig)
.then(compiledFilename => {
if (options.afterCompilation) {
options.afterCompilation(compiledFilename);
}
})
.catch(options.onError);
});
cssWatcher.on('error', options.onError);
}
module.exports = watchCss;