New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
refactor: some improvements for webpack-dev-server #5815
Changes from 1 commit
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -109,13 +109,16 @@ export default async function start( | |
}), | ||
]; | ||
|
||
const fsWatcher = chokidar.watch(pathsToWatch, { | ||
cwd: siteDir, | ||
ignoreInitial: true, | ||
const pollingOptions = { | ||
usePolling: !!cliOptions.poll, | ||
interval: Number.isInteger(cliOptions.poll) | ||
? (cliOptions.poll as number) | ||
: undefined, | ||
}; | ||
const fsWatcher = chokidar.watch(pathsToWatch, { | ||
cwd: siteDir, | ||
ignoreInitial: true, | ||
...{pollingOptions}, | ||
}); | ||
|
||
['add', 'change', 'unlink', 'addDir', 'unlinkDir'].forEach((event) => | ||
|
@@ -166,8 +169,8 @@ export default async function start( | |
|
||
// https://webpack.js.org/configuration/dev-server | ||
const devServerConfig: WebpackDevServer.Configuration = { | ||
compress: true, | ||
hot: cliOptions.hotOnly ? 'only' : true, | ||
liveReload: false, | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. We always use |
||
client: { | ||
progress: true, | ||
overlay: { | ||
|
@@ -182,17 +185,16 @@ export default async function start( | |
devMiddleware: { | ||
publicPath: baseUrl, | ||
// Reduce log verbosity, see https://github.com/facebook/docusaurus/pull/5420#issuecomment-906613105 | ||
stats: 'errors-warnings', | ||
stats: 'summary', | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Perhaps we should use "stats" because the current value duplicates the output in case of error: BeforeSyntaxError: /website/docs/blog.mdx: Expected corresponding JSX closing tag for <MDXLayout>. (14:0) 12 | <p>{`sdfsds`}</p> 13 | <p>{`sdfsd`}</p> > 14 | </> | ^ 15 | <p>{`The blog feature enables you to deploy in no time a full-featured blog.`}</p> 16 | <div {...{"className":"admonition admonition-info alert alert--info"}}><div parentName="div" {...{"className":"admonition-heading"}}><h5 parentName="div"><span parentName="h5" {...{"className":"admonition-icon"}}><svg parentName="span" {...{"xmlns":"http://www.w3.org/2000/svg","width":"14","height":"16","viewBox":"0 0 14 16"}}><path parentName="svg" {...{"fillRule":"evenodd","d":"M7 2.3c3.14 0 5.7 2.56 5.7 5.7s-2.56 5.7-5.7 5.7A5.71 5.71 0 0 1 1.3 8c0-3.14 2.56-5.7 5.7-5.7zM7 1C3.14 1 0 4.14 0 8s3.14 7 7 7 7-3.14 7-7-3.14-7-7-7zm1 3H6v5h2V4zm0 6H6v2h2v-2z"}}></path></svg></span>{`info`}</h5></div><div parentName="div" {...{"className":"admonition-content"}}><p parentName="div">{`Check the `}<a parentName="p" {...{"href":"/docs/api/plugins/@docusaurus/plugin-content-blog"}}>{`Blog Plugin API Reference documentation`}</a>{` for an exhaustive list of options.`}</p></div></div> 17 | <h2 {...{"id":"initial-setup"}}>{`Initial setup`}</h2> ERROR in ./docs/blog.mdx Module build failed (from ../packages/docusaurus-mdx-loader/lib/index.js): SyntaxError: /website/docs/blog.mdx: Expected corresponding JSX closing tag for <MDXLayout>. (14:0) AfterSyntaxError: /home/lex/repos/docusaurus/website/docs/blog.mdx: Expected corresponding JSX closing tag for <MDXLayout>. (14:0) 12 | <p>{`sdfsds`}</p> 13 | <p>{`sdfsd`}</p> > 14 | </> | ^ 15 | <p>{`The blog feature enables you to deploy in no time a full-featured blog.`}</p> 16 | <div {...{"className":"admonition admonition-info alert alert--info"}}><div parentName="div" {...{"className":"admonition-heading"}}><h5 parentName="div"><span parentName="h5" {...{"className":"admonition-icon"}}><svg parentName="span" {...{"xmlns":"http://www.w3.org/2000/svg","width":"14","height":"16","viewBox":"0 0 14 16"}}><path parentName="svg" {...{"fillRule":"evenodd","d":"M7 2.3c3.14 0 5.7 2.56 5.7 5.7s-2.56 5.7-5.7 5.7A5.71 5.71 0 0 1 1.3 8c0-3.14 2.56-5.7 5.7-5.7zM7 1C3.14 1 0 4.14 0 8s3.14 7 7 7 7-3.14 7-7-3.14-7-7-7zm1 3H6v5h2V4zm0 6H6v2h2v-2z"}}></path></svg></span>{`info`}</h5></div><div parentName="div" {...{"className":"admonition-content"}}><p parentName="div">{`Check the `}<a parentName="p" {...{"href":"/docs/api/plugins/@docusaurus/plugin-content-blog"}}>{`Blog Plugin API Reference documentation`}</a>{` for an exhaustive list of options.`}</p></div></div> 17 | <h2 {...{"id":"initial-setup"}}>{`Initial setup`}</h2> client (webpack 5.60.0) compiled with 1 error |
||
}, | ||
static: { | ||
directory: path.resolve(siteDir, STATIC_DIR_NAME), | ||
watch: { | ||
usePolling: !!cliOptions.poll, | ||
|
||
// Useful options for our own monorepo using symlinks! | ||
// See https://github.com/webpack/webpack/issues/11612#issuecomment-879259806 | ||
followSymlinks: true, | ||
ignored: /node_modules\/(?!@docusaurus)/, | ||
...{pollingOptions}, | ||
}, | ||
}, | ||
historyApiFallback: { | ||
|
@@ -233,7 +235,7 @@ export default async function start( | |
|
||
['SIGINT', 'SIGTERM'].forEach((sig) => { | ||
process.on(sig as NodeJS.Signals, () => { | ||
devServer.close(); | ||
devServer.stop(); | ||
process.exit(); | ||
}); | ||
}); | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
watch
accepts chokidar options, and it seems to make sense to passinterval
in addition tousePolling
.