Skip to content
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

feat(v2): add CLI option for polling #2630

Merged
merged 3 commits into from
Apr 20, 2020
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions packages/docusaurus-types/src/index.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,7 @@ export interface StartCLIOptions {
host: string;
hotOnly: boolean;
open: boolean;
poll: boolean;
}

export interface BuildCLIOptions {
Expand Down
7 changes: 6 additions & 1 deletion packages/docusaurus/bin/docusaurus.js
Original file line number Diff line number Diff line change
Expand Up @@ -85,12 +85,17 @@ cli
'Do not fallback to page refresh if hot reload fails (default: false)',
)
.option('--no-open', 'Do not open page in the browser (default: false)')
.action((siteDir = '.', {port, host, hotOnly, open}) => {
.option(
'--poll',
'Use polling rather than wathcing for reload (default: false)',
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

typo: wathcing -> watching

)
.action((siteDir = '.', {port, host, hotOnly, open, poll}) => {
wrapCommand(start)(path.resolve(siteDir), {
port,
host,
hotOnly,
open,
poll,
});
});

Expand Down
1 change: 1 addition & 0 deletions packages/docusaurus/src/commands/start.ts
Original file line number Diff line number Diff line change
Expand Up @@ -141,6 +141,7 @@ export async function start(
publicPath: baseUrl,
watchOptions: {
ignored: /node_modules/,
poll: cliOptions.poll,
},
historyApiFallback: {
rewrites: [{from: /\/*/, to: baseUrl}],
Expand Down
1 change: 1 addition & 0 deletions website/docs/cli.md
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,7 @@ Builds and serves a preview of your site locally with [Webpack Dev Server](https
| `--host` | `localhost` | Specify a host to use. E.g., if you want your server to be accessible externally, you can use `--host 0.0.0.0` |
| `--hot-only` | `false` | Enables Hot Module Replacement without page refresh as fallback in case of build failures. More information [here](https://webpack.js.org/configuration/dev-server/#devserverhotonly). |
| `--no-open` | `false` | Do not open automatically the page in the browser. |
| `--poll` | `false` | Use polling of files rather than watching for live reload as a fallback in enviroments where watching doesn't work. More information [here](https://webpack.js.org/configuration/watch/#watchoptionspoll). |

:::important

Expand Down