diff --git a/packages/docusaurus/bin/docusaurus.js b/packages/docusaurus/bin/docusaurus.js index a8159fa5db6b..1aeee719afa0 100755 --- a/packages/docusaurus/bin/docusaurus.js +++ b/packages/docusaurus/bin/docusaurus.js @@ -80,17 +80,15 @@ program .description('Start development server') .option('-p, --port ', 'use specified port (default: 3000)') .option('-h, --host ', 'use specified host (default: localhost') - .option('-nw, --no-watch ', 'disable live reload (default: false)') .option( '--hot-only', 'Do not fallback to page refresh if hot reload fails (default: false)', ) .option('--no-cache-loader', 'Do not use cache-loader') - .action((siteDir = '.', {port, host, noWatch, hotOnly, cacheLoader}) => { + .action((siteDir = '.', {port, host, hotOnly, cacheLoader}) => { wrapCommand(start)(path.resolve(siteDir), { port, host, - noWatch, hotOnly, cacheLoader, }); diff --git a/packages/docusaurus/src/commands/start.js b/packages/docusaurus/src/commands/start.js index 46c6f2bc37b9..475fc69c57c0 100644 --- a/packages/docusaurus/src/commands/start.js +++ b/packages/docusaurus/src/commands/start.js @@ -41,36 +41,32 @@ module.exports = async function start(siteDir, cliOptions = {}) { const props = await load(siteDir, cliOptions); // Reload files processing. - if (!cliOptions.noWatch) { - const reload = () => { - load(siteDir).catch(err => { - console.error(chalk.red(err.stack)); - }); - }; - const {plugins} = props; + const reload = () => { + load(siteDir).catch(err => { + console.error(chalk.red(err.stack)); + }); + }; + const {siteConfig, plugins = []} = props; - const normalizeToSiteDir = filepath => { - if (filepath && path.isAbsolute(filepath)) { - return path.relative(siteDir, filepath); - } - return filepath; - }; + const normalizeToSiteDir = filepath => { + if (filepath && path.isAbsolute(filepath)) { + return path.relative(siteDir, filepath); + } + return filepath; + }; - const pluginPaths = _.compact( - _.flatten( - plugins.map( - plugin => plugin.getPathsToWatch && plugin.getPathsToWatch(), - ), - ), - ).map(normalizeToSiteDir); - const fsWatcher = chokidar.watch([...pluginPaths, CONFIG_FILE_NAME], { - cwd: siteDir, - ignoreInitial: true, - }); - ['add', 'change', 'unlink', 'addDir', 'unlinkDir'].forEach(event => - fsWatcher.on(event, reload), - ); - } + const pluginPaths = _.compact( + _.flatten( + plugins.map(plugin => plugin.getPathsToWatch && plugin.getPathsToWatch()), + ), + ).map(normalizeToSiteDir); + const fsWatcher = chokidar.watch([...pluginPaths, CONFIG_FILE_NAME], { + cwd: siteDir, + ignoreInitial: true, + }); + ['add', 'change', 'unlink', 'addDir', 'unlinkDir'].forEach(event => + fsWatcher.on(event, reload), + ); const protocol = process.env.HTTPS === 'true' ? 'https' : 'http'; const port = await getPort(cliOptions.port); @@ -79,7 +75,6 @@ module.exports = async function start(siteDir, cliOptions = {}) { const urls = prepareUrls(protocol, host, port); const openUrl = normalizeUrl([urls.localUrlForBrowser, baseUrl]); - const {siteConfig, plugins = []} = props; let config = merge(createClientConfig(props), { plugins: [ // Generates an `index.html` file with the