mirror of
https://github.com/facebook/docusaurus.git
synced 2025-08-06 10:20:09 +02:00
fix(v2): chokidar reloading debounced (#4080)
This commit is contained in:
parent
a2efe9fda7
commit
d6d30a39fc
1 changed files with 3 additions and 2 deletions
|
@ -11,6 +11,7 @@ import chokidar from 'chokidar';
|
||||||
import express from 'express';
|
import express from 'express';
|
||||||
import HtmlWebpackPlugin from 'html-webpack-plugin';
|
import HtmlWebpackPlugin from 'html-webpack-plugin';
|
||||||
import path from 'path';
|
import path from 'path';
|
||||||
|
import debounce from 'lodash/debounce';
|
||||||
import openBrowser from 'react-dev-utils/openBrowser';
|
import openBrowser from 'react-dev-utils/openBrowser';
|
||||||
import {prepareUrls} from 'react-dev-utils/WebpackDevServerUtils';
|
import {prepareUrls} from 'react-dev-utils/WebpackDevServerUtils';
|
||||||
import errorOverlayMiddleware from 'react-dev-utils/errorOverlayMiddleware';
|
import errorOverlayMiddleware from 'react-dev-utils/errorOverlayMiddleware';
|
||||||
|
@ -61,7 +62,7 @@ export default async function start(
|
||||||
console.log(chalk.cyanBright(`Docusaurus website is running at: ${openUrl}`));
|
console.log(chalk.cyanBright(`Docusaurus website is running at: ${openUrl}`));
|
||||||
|
|
||||||
// Reload files processing.
|
// Reload files processing.
|
||||||
const reload = () => {
|
const reload = debounce(() => {
|
||||||
loadSite()
|
loadSite()
|
||||||
.then(({baseUrl: newBaseUrl}) => {
|
.then(({baseUrl: newBaseUrl}) => {
|
||||||
const newOpenUrl = normalizeUrl([urls.localUrlForBrowser, newBaseUrl]);
|
const newOpenUrl = normalizeUrl([urls.localUrlForBrowser, newBaseUrl]);
|
||||||
|
@ -72,7 +73,7 @@ export default async function start(
|
||||||
.catch((err) => {
|
.catch((err) => {
|
||||||
console.error(chalk.red(err.stack));
|
console.error(chalk.red(err.stack));
|
||||||
});
|
});
|
||||||
};
|
}, 500);
|
||||||
const {siteConfig, plugins = []} = props;
|
const {siteConfig, plugins = []} = props;
|
||||||
|
|
||||||
const normalizeToSiteDir = (filepath) => {
|
const normalizeToSiteDir = (filepath) => {
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue