misc(v2): misc fixes

This commit is contained in:
Yangshun Tay 2019-03-04 22:39:07 -08:00
parent 95b0cb942f
commit d64581f2b4
9 changed files with 27 additions and 34 deletions

View file

@ -47,7 +47,7 @@ module.exports = async function build(siteDir) {
let serverConfig = createServerConfig(props).toConfig();
let clientConfig = createClientConfig(props).toConfig();
// apply user webpack config
// Apply user webpack config.
const {
siteConfig: {configureWebpack},
} = props;
@ -61,7 +61,7 @@ module.exports = async function build(siteDir) {
// Build the server bundles (render the static HTML and pick client bundle)
await compile(serverConfig);
// copy static files
// Copy static files.
const {outDir} = props;
const staticDir = path.resolve(siteDir, 'static');
const staticFiles = await globby(['**'], {
@ -75,7 +75,7 @@ module.exports = async function build(siteDir) {
}),
);
// generate sitemap
// Generate sitemap.
const sitemap = await createSitemap(props);
const sitemapPath = path.join(outDir, 'sitemap.xml');
await fs.writeFile(sitemapPath, sitemap);

View file

@ -49,8 +49,8 @@ module.exports = async function start(siteDir, cliOptions = {}) {
const docsRelativeDir = props.siteConfig.customDocsPath;
const fsWatcher = chokidar.watch(
[
// TODO: Watch plugin paths (e.g. blog)
`../${docsRelativeDir}/**/*.md`,
'blog/**/*.md',
loadConfig.configFileName,
'sidebars.json',
],
@ -59,11 +59,9 @@ module.exports = async function start(siteDir, cliOptions = {}) {
ignoreInitial: true,
},
);
fsWatcher.on('add', reload);
fsWatcher.on('change', reload);
fsWatcher.on('unlink', reload);
fsWatcher.on('addDir', reload);
fsWatcher.on('unlinkDir', reload);
['add', 'change', 'unlink', 'addDir', 'unlinkDir'].forEach(event =>
fsWatcher.on(event, reload),
);
}
const port = await getPort(cliOptions.port);