Skip to content

Instantly share code, notes, and snippets.

@Nazar32
Created September 5, 2019 14:22
Show Gist options
  • Select an option

  • Save Nazar32/de20d2fae38248532be1855d50409564 to your computer and use it in GitHub Desktop.

Select an option

Save Nazar32/de20d2fae38248532be1855d50409564 to your computer and use it in GitHub Desktop.
const chokidar = require('chokidar');
const watcher = chokidar.watch('.', {
ignored: '/\\.(png|jpg|gif|svg)$/',
});
watcher.on('ready', () => {
console.log('ready');
watcher.on('all', (event, path) => {
console.log(`all ${path}`);
Object.keys(require.cache).forEach((id) => {
delete require.cache[id];
if (/[\/\\]dist[\/\\]/.test(id) && delete require.cache[id]) {
console.log(`Clearing ${id} module cache`);
}
});
});
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment