mirror of
https://github.com/facebook/docusaurus.git
synced 2025-05-23 22:17:00 +02:00
feat(v2): report port number when starting dev server (#1582)
* feat(v2): report port number when starting dev server * Attempt to print dev server URL * Use digit dino * Resolve merge conflict * remove dino
This commit is contained in:
parent
80df0c00f2
commit
a6736dd8dc
2 changed files with 5 additions and 2 deletions
|
@ -19,9 +19,9 @@ import webpack from 'webpack';
|
||||||
import WebpackDevServer from 'webpack-dev-server';
|
import WebpackDevServer from 'webpack-dev-server';
|
||||||
import merge from 'webpack-merge';
|
import merge from 'webpack-merge';
|
||||||
import HotModuleReplacementPlugin from 'webpack/lib/HotModuleReplacementPlugin';
|
import HotModuleReplacementPlugin from 'webpack/lib/HotModuleReplacementPlugin';
|
||||||
import {CONFIG_FILE_NAME, STATIC_DIR_NAME} from '../constants';
|
|
||||||
import {load} from '../server';
|
import {load} from '../server';
|
||||||
import {CLIOptions} from '../server/types';
|
import {CLIOptions} from '../server/types';
|
||||||
|
import {CONFIG_FILE_NAME, STATIC_DIR_NAME, DEFAULT_PORT} from '../constants';
|
||||||
import {createClientConfig} from '../webpack/client';
|
import {createClientConfig} from '../webpack/client';
|
||||||
import {applyConfigureWebpack} from '../webpack/utils';
|
import {applyConfigureWebpack} from '../webpack/utils';
|
||||||
|
|
||||||
|
@ -30,7 +30,7 @@ function getHost(reqHost: string | undefined): string {
|
||||||
}
|
}
|
||||||
|
|
||||||
async function getPort(reqPort: string | undefined): Promise<number> {
|
async function getPort(reqPort: string | undefined): Promise<number> {
|
||||||
const basePort = reqPort ? parseInt(reqPort, 10) : 3000;
|
const basePort = reqPort ? parseInt(reqPort, 10) : DEFAULT_PORT;
|
||||||
const port = await portfinder.getPortPromise({port: basePort});
|
const port = await portfinder.getPortPromise({port: basePort});
|
||||||
return port;
|
return port;
|
||||||
}
|
}
|
||||||
|
@ -79,6 +79,8 @@ export async function start(
|
||||||
const urls = prepareUrls(protocol, host, port);
|
const urls = prepareUrls(protocol, host, port);
|
||||||
const openUrl = normalizeUrl([urls.localUrlForBrowser, baseUrl]);
|
const openUrl = normalizeUrl([urls.localUrlForBrowser, baseUrl]);
|
||||||
|
|
||||||
|
console.log(chalk.cyan(`Your site will be accessible at ${openUrl}`));
|
||||||
|
|
||||||
let config: webpack.Configuration = merge(createClientConfig(props), {
|
let config: webpack.Configuration = merge(createClientConfig(props), {
|
||||||
plugins: [
|
plugins: [
|
||||||
// Generates an `index.html` file with the <script> injected.
|
// Generates an `index.html` file with the <script> injected.
|
||||||
|
|
|
@ -11,3 +11,4 @@ export const GENERATED_FILES_DIR_NAME = '.docusaurus';
|
||||||
export const SRC_DIR_NAME = 'src';
|
export const SRC_DIR_NAME = 'src';
|
||||||
export const STATIC_DIR_NAME = 'static';
|
export const STATIC_DIR_NAME = 'static';
|
||||||
export const THEME_PATH = `${SRC_DIR_NAME}/theme`;
|
export const THEME_PATH = `${SRC_DIR_NAME}/theme`;
|
||||||
|
export const DEFAULT_PORT = 3000;
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue