mirror of
https://github.com/facebook/docusaurus.git
synced 2025-12-26 01:33:02 +00:00
feat(v2): Add console output with complete URL including the baseUrl (#3541)
* Add console output with complete URL including the baseUrl * Add output when website loads for first time, corrects sentence for clarity
This commit is contained in:
parent
10973476ff
commit
2e9854964d
|
|
@ -37,11 +37,33 @@ export default async function start(
|
|||
// Process all related files as a prop.
|
||||
const props = await load(siteDir);
|
||||
|
||||
const protocol: string = process.env.HTTPS === 'true' ? 'https' : 'http';
|
||||
|
||||
const host: string = getCLIOptionHost(cliOptions.host);
|
||||
const port: number | null = await getCLIOptionPort(cliOptions.port, host);
|
||||
|
||||
if (port === null) {
|
||||
process.exit();
|
||||
}
|
||||
|
||||
const {baseUrl, headTags, preBodyTags, postBodyTags} = props;
|
||||
const urls = prepareUrls(protocol, host, port);
|
||||
const openUrl = normalizeUrl([urls.localUrlForBrowser, baseUrl]);
|
||||
|
||||
console.log(chalk.cyanBright(`Docusaurus website is running at: ${openUrl}`));
|
||||
|
||||
// Reload files processing.
|
||||
const reload = () => {
|
||||
load(siteDir).catch((err) => {
|
||||
console.error(chalk.red(err.stack));
|
||||
});
|
||||
load(siteDir)
|
||||
.then(({baseUrl: newBaseUrl}) => {
|
||||
const newOpenUrl = normalizeUrl([urls.localUrlForBrowser, newBaseUrl]);
|
||||
console.log(
|
||||
chalk.cyanBright(`Docusaurus website is running at: ${newOpenUrl}`),
|
||||
);
|
||||
})
|
||||
.catch((err) => {
|
||||
console.error(chalk.red(err.stack));
|
||||
});
|
||||
};
|
||||
const {siteConfig, plugins = []} = props;
|
||||
|
||||
|
|
@ -67,19 +89,6 @@ export default async function start(
|
|||
fsWatcher.on(event, reload),
|
||||
);
|
||||
|
||||
const protocol: string = process.env.HTTPS === 'true' ? 'https' : 'http';
|
||||
|
||||
const host: string = getCLIOptionHost(cliOptions.host);
|
||||
const port: number | null = await getCLIOptionPort(cliOptions.port, host);
|
||||
|
||||
if (port === null) {
|
||||
process.exit();
|
||||
}
|
||||
|
||||
const {baseUrl, headTags, preBodyTags, postBodyTags} = props;
|
||||
const urls = prepareUrls(protocol, host, port);
|
||||
const openUrl = normalizeUrl([urls.localUrlForBrowser, baseUrl]);
|
||||
|
||||
let config: webpack.Configuration = merge(createClientConfig(props), {
|
||||
plugins: [
|
||||
// Generates an `index.html` file with the <script> injected.
|
||||
|
|
|
|||
Loading…
Reference in New Issue