mirror of
https://github.com/facebook/docusaurus.git
synced 2025-07-30 15:00:09 +02:00
chore: remove noWatch cli options because you cant disable watch in wds (#1480)
This commit is contained in:
parent
05ba7d835d
commit
1ec4a9f999
3 changed files with 27 additions and 37 deletions
|
@ -80,17 +80,15 @@ program
|
||||||
.description('Start development server')
|
.description('Start development server')
|
||||||
.option('-p, --port <port>', 'use specified port (default: 3000)')
|
.option('-p, --port <port>', 'use specified port (default: 3000)')
|
||||||
.option('-h, --host <host>', 'use specified host (default: localhost')
|
.option('-h, --host <host>', 'use specified host (default: localhost')
|
||||||
.option('-nw, --no-watch <noWatch>', 'disable live reload (default: false)')
|
|
||||||
.option(
|
.option(
|
||||||
'--hot-only',
|
'--hot-only',
|
||||||
'Do not fallback to page refresh if hot reload fails (default: false)',
|
'Do not fallback to page refresh if hot reload fails (default: false)',
|
||||||
)
|
)
|
||||||
.option('--no-cache-loader', 'Do not use cache-loader')
|
.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), {
|
wrapCommand(start)(path.resolve(siteDir), {
|
||||||
port,
|
port,
|
||||||
host,
|
host,
|
||||||
noWatch,
|
|
||||||
hotOnly,
|
hotOnly,
|
||||||
cacheLoader,
|
cacheLoader,
|
||||||
});
|
});
|
||||||
|
|
|
@ -41,13 +41,12 @@ module.exports = async function start(siteDir, cliOptions = {}) {
|
||||||
const props = await load(siteDir, cliOptions);
|
const props = await load(siteDir, cliOptions);
|
||||||
|
|
||||||
// Reload files processing.
|
// Reload files processing.
|
||||||
if (!cliOptions.noWatch) {
|
|
||||||
const reload = () => {
|
const reload = () => {
|
||||||
load(siteDir).catch(err => {
|
load(siteDir).catch(err => {
|
||||||
console.error(chalk.red(err.stack));
|
console.error(chalk.red(err.stack));
|
||||||
});
|
});
|
||||||
};
|
};
|
||||||
const {plugins} = props;
|
const {siteConfig, plugins = []} = props;
|
||||||
|
|
||||||
const normalizeToSiteDir = filepath => {
|
const normalizeToSiteDir = filepath => {
|
||||||
if (filepath && path.isAbsolute(filepath)) {
|
if (filepath && path.isAbsolute(filepath)) {
|
||||||
|
@ -58,9 +57,7 @@ module.exports = async function start(siteDir, cliOptions = {}) {
|
||||||
|
|
||||||
const pluginPaths = _.compact(
|
const pluginPaths = _.compact(
|
||||||
_.flatten(
|
_.flatten(
|
||||||
plugins.map(
|
plugins.map(plugin => plugin.getPathsToWatch && plugin.getPathsToWatch()),
|
||||||
plugin => plugin.getPathsToWatch && plugin.getPathsToWatch(),
|
|
||||||
),
|
|
||||||
),
|
),
|
||||||
).map(normalizeToSiteDir);
|
).map(normalizeToSiteDir);
|
||||||
const fsWatcher = chokidar.watch([...pluginPaths, CONFIG_FILE_NAME], {
|
const fsWatcher = chokidar.watch([...pluginPaths, CONFIG_FILE_NAME], {
|
||||||
|
@ -70,7 +67,6 @@ module.exports = async function start(siteDir, cliOptions = {}) {
|
||||||
['add', 'change', 'unlink', 'addDir', 'unlinkDir'].forEach(event =>
|
['add', 'change', 'unlink', 'addDir', 'unlinkDir'].forEach(event =>
|
||||||
fsWatcher.on(event, reload),
|
fsWatcher.on(event, reload),
|
||||||
);
|
);
|
||||||
}
|
|
||||||
|
|
||||||
const protocol = process.env.HTTPS === 'true' ? 'https' : 'http';
|
const protocol = process.env.HTTPS === 'true' ? 'https' : 'http';
|
||||||
const port = await getPort(cliOptions.port);
|
const port = await getPort(cliOptions.port);
|
||||||
|
@ -79,7 +75,6 @@ module.exports = async function start(siteDir, cliOptions = {}) {
|
||||||
const urls = prepareUrls(protocol, host, port);
|
const urls = prepareUrls(protocol, host, port);
|
||||||
const openUrl = normalizeUrl([urls.localUrlForBrowser, baseUrl]);
|
const openUrl = normalizeUrl([urls.localUrlForBrowser, baseUrl]);
|
||||||
|
|
||||||
const {siteConfig, plugins = []} = props;
|
|
||||||
let config = merge(createClientConfig(props), {
|
let config = merge(createClientConfig(props), {
|
||||||
plugins: [
|
plugins: [
|
||||||
// Generates an `index.html` file with the <script> injected.
|
// Generates an `index.html` file with the <script> injected.
|
||||||
|
@ -115,12 +110,10 @@ module.exports = async function start(siteDir, cliOptions = {}) {
|
||||||
compress: true,
|
compress: true,
|
||||||
clientLogLevel: 'error',
|
clientLogLevel: 'error',
|
||||||
hot: true,
|
hot: true,
|
||||||
// Do not fallback to page refresh if hot reload fails
|
|
||||||
// https://webpack.js.org/configuration/dev-server/#devserverhotonly
|
|
||||||
hotOnly: cliOptions.hotOnly,
|
hotOnly: cliOptions.hotOnly,
|
||||||
quiet: true,
|
quiet: true,
|
||||||
headers: {
|
headers: {
|
||||||
'access-control-allow-origin': '*', // Needed for CORS.
|
'access-control-allow-origin': '*',
|
||||||
},
|
},
|
||||||
publicPath: baseUrl,
|
publicPath: baseUrl,
|
||||||
watchOptions: {
|
watchOptions: {
|
||||||
|
|
|
@ -47,7 +47,6 @@ Builds and serves the static site with [Webpack Dev Server](https://webpack.js.o
|
||||||
|-|-|-|
|
|-|-|-|
|
||||||
|`--port`|`3000`|Specifies the port of the dev server|
|
|`--port`|`3000`|Specifies the port of the dev server|
|
||||||
|`--host`|`localhost`|Specifie a host to use. E.g., if you want your server to be accessible externally, you can use `--host 0.0.0.0`|
|
|`--host`|`localhost`|Specifie a host to use. E.g., if you want your server to be accessible externally, you can use `--host 0.0.0.0`|
|
||||||
|`--no-watch`|`false`|<!-- TODO problematic atm --> Disables watching files for hot reload|
|
|
||||||
|`--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).|
|
|`--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).|
|
||||||
|
|
||||||
### `docusaurus build`
|
### `docusaurus build`
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue