mirror of
https://github.com/facebook/docusaurus.git
synced 2025-05-10 07:37:19 +02:00
chore: prettier
This commit is contained in:
parent
05426d4e2c
commit
187a46d9b6
2 changed files with 24 additions and 22 deletions
|
@ -61,5 +61,5 @@ program
|
|||
program.parse(process.argv);
|
||||
|
||||
if (!process.argv.slice(2).length) {
|
||||
program.outputHelp()
|
||||
program.outputHelp();
|
||||
}
|
|
@ -21,16 +21,17 @@ async function getPort(port) {
|
|||
}
|
||||
|
||||
module.exports = async function start(siteDir, cliOptions = {}) {
|
||||
// load site props from preprocessed files in source directory
|
||||
// Preprocess whole files as a prop
|
||||
const props = await load(siteDir);
|
||||
|
||||
// Reload for any add/change/remove of file
|
||||
// (if enabled) live reload for any changes in file
|
||||
if (!cliOptions.noWatch) {
|
||||
const reload = () => {
|
||||
load(siteDir).catch(err => {
|
||||
console.error(chalk.red(err.stack));
|
||||
});
|
||||
};
|
||||
const fsWatcher = chokidar.watch(['**/*.md', 'config.js'], {
|
||||
const fsWatcher = chokidar.watch(['../docs/**/*.md', 'siteConfig.js'], {
|
||||
cwd: siteDir,
|
||||
ignoreInitial: true
|
||||
});
|
||||
|
@ -39,9 +40,10 @@ module.exports = async function start(siteDir, cliOptions = {}) {
|
|||
fsWatcher.on('unlink', reload);
|
||||
fsWatcher.on('addDir', reload);
|
||||
fsWatcher.on('unlinkDir', reload);
|
||||
}
|
||||
|
||||
const port = await getPort(cliOptions.port);
|
||||
const {publicPath} = props;
|
||||
const {baseUrl} = props;
|
||||
|
||||
// resolve webpack config
|
||||
let config = createDevConfig(props);
|
||||
|
@ -51,7 +53,7 @@ module.exports = async function start(siteDir, cliOptions = {}) {
|
|||
onDone: () => {
|
||||
console.log(
|
||||
`\n${chalk.blue('Development server available at ')}${chalk.cyan(
|
||||
`http://localhost:${port}${publicPath}`
|
||||
`http://localhost:${port}${baseUrl}`
|
||||
)}`
|
||||
);
|
||||
}
|
||||
|
@ -89,9 +91,9 @@ module.exports = async function start(siteDir, cliOptions = {}) {
|
|||
logLevel: 'error',
|
||||
port,
|
||||
add: (app, middleware, options) => {
|
||||
const staticDir = path.resolve(siteDir, 'public');
|
||||
const staticDir = path.resolve(siteDir, 'static');
|
||||
if (fs.existsSync(staticDir)) {
|
||||
app.use(mount(publicPath, serveStatic(staticDir)));
|
||||
app.use(mount(baseUrl, serveStatic(staticDir)));
|
||||
}
|
||||
app.use(range); // enable range request https://tools.ietf.org/html/rfc7233
|
||||
app.use(
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue