mirror of
https://github.com/facebook/docusaurus.git
synced 2025-05-07 06:07:42 +02:00
refactor: some improvements for webpack-dev-server (#5815)
This commit is contained in:
parent
157b41caee
commit
d1fa1b5d35
1 changed files with 10 additions and 8 deletions
|
@ -109,13 +109,16 @@ export default async function start(
|
||||||
}),
|
}),
|
||||||
];
|
];
|
||||||
|
|
||||||
const fsWatcher = chokidar.watch(pathsToWatch, {
|
const pollingOptions = {
|
||||||
cwd: siteDir,
|
|
||||||
ignoreInitial: true,
|
|
||||||
usePolling: !!cliOptions.poll,
|
usePolling: !!cliOptions.poll,
|
||||||
interval: Number.isInteger(cliOptions.poll)
|
interval: Number.isInteger(cliOptions.poll)
|
||||||
? (cliOptions.poll as number)
|
? (cliOptions.poll as number)
|
||||||
: undefined,
|
: undefined,
|
||||||
|
};
|
||||||
|
const fsWatcher = chokidar.watch(pathsToWatch, {
|
||||||
|
cwd: siteDir,
|
||||||
|
ignoreInitial: true,
|
||||||
|
...{pollingOptions},
|
||||||
});
|
});
|
||||||
|
|
||||||
['add', 'change', 'unlink', 'addDir', 'unlinkDir'].forEach((event) =>
|
['add', 'change', 'unlink', 'addDir', 'unlinkDir'].forEach((event) =>
|
||||||
|
@ -166,8 +169,8 @@ export default async function start(
|
||||||
|
|
||||||
// https://webpack.js.org/configuration/dev-server
|
// https://webpack.js.org/configuration/dev-server
|
||||||
const devServerConfig: WebpackDevServer.Configuration = {
|
const devServerConfig: WebpackDevServer.Configuration = {
|
||||||
compress: true,
|
|
||||||
hot: cliOptions.hotOnly ? 'only' : true,
|
hot: cliOptions.hotOnly ? 'only' : true,
|
||||||
|
liveReload: false,
|
||||||
client: {
|
client: {
|
||||||
progress: true,
|
progress: true,
|
||||||
overlay: {
|
overlay: {
|
||||||
|
@ -182,17 +185,16 @@ export default async function start(
|
||||||
devMiddleware: {
|
devMiddleware: {
|
||||||
publicPath: baseUrl,
|
publicPath: baseUrl,
|
||||||
// Reduce log verbosity, see https://github.com/facebook/docusaurus/pull/5420#issuecomment-906613105
|
// Reduce log verbosity, see https://github.com/facebook/docusaurus/pull/5420#issuecomment-906613105
|
||||||
stats: 'errors-warnings',
|
stats: 'summary',
|
||||||
},
|
},
|
||||||
static: {
|
static: {
|
||||||
directory: path.resolve(siteDir, STATIC_DIR_NAME),
|
directory: path.resolve(siteDir, STATIC_DIR_NAME),
|
||||||
watch: {
|
watch: {
|
||||||
usePolling: !!cliOptions.poll,
|
|
||||||
|
|
||||||
// Useful options for our own monorepo using symlinks!
|
// Useful options for our own monorepo using symlinks!
|
||||||
// See https://github.com/webpack/webpack/issues/11612#issuecomment-879259806
|
// See https://github.com/webpack/webpack/issues/11612#issuecomment-879259806
|
||||||
followSymlinks: true,
|
followSymlinks: true,
|
||||||
ignored: /node_modules\/(?!@docusaurus)/,
|
ignored: /node_modules\/(?!@docusaurus)/,
|
||||||
|
...{pollingOptions},
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
historyApiFallback: {
|
historyApiFallback: {
|
||||||
|
@ -233,7 +235,7 @@ export default async function start(
|
||||||
|
|
||||||
['SIGINT', 'SIGTERM'].forEach((sig) => {
|
['SIGINT', 'SIGTERM'].forEach((sig) => {
|
||||||
process.on(sig, () => {
|
process.on(sig, () => {
|
||||||
devServer.close();
|
devServer.stop();
|
||||||
process.exit();
|
process.exit();
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
Loading…
Add table
Reference in a new issue