feat(v2): allow plugins to specify paths to watch (#1272)

This commit is contained in:
Yangshun Tay 2019-03-09 13:00:44 -08:00 committed by GitHub
parent 8629abf73a
commit cefee2dec1
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
6 changed files with 27 additions and 14 deletions

View file

@ -5,6 +5,7 @@
* LICENSE file in the root directory of this source tree.
*/
const _ = require('lodash');
const path = require('path');
const fs = require('fs-extra');
const chalk = require('chalk');
@ -46,10 +47,14 @@ module.exports = async function start(siteDir, cliOptions = {}) {
console.error(chalk.red(err.stack));
});
};
const {plugins} = props;
const docsRelativeDir = props.siteConfig.customDocsPath;
const pluginPaths = _.flatten(
plugins.map(plugin => plugin.getPathsToWatch()),
);
const fsWatcher = chokidar.watch(
[
// TODO: Watch plugin paths (e.g. blog)
...pluginPaths,
`../${docsRelativeDir}/**/*.md`,
loadConfig.configFileName,
'sidebars.json',