Skip to content

Commit

Permalink
fix(v2): should be able to build even if static folder doesnt exist
Browse files Browse the repository at this point in the history
  • Loading branch information
endiliey committed May 17, 2019
1 parent 89ef4b9 commit a32ce81
Showing 1 changed file with 12 additions and 10 deletions.
22 changes: 12 additions & 10 deletions packages/docusaurus/src/commands/build.js
Original file line number Diff line number Diff line change
Expand Up @@ -92,16 +92,18 @@ module.exports = async function build(siteDir, cliOptions = {}) {

// Copy static files.
const staticDir = path.resolve(siteDir, 'static');
const staticFiles = await globby(['**'], {
cwd: staticDir,
});
await Promise.all(
staticFiles.map(async source => {
const fromPath = path.resolve(staticDir, source);
const toPath = path.resolve(outDir, source);
return fs.copy(fromPath, toPath);
}),
);
if (fs.existsSync(staticDir)) {
const staticFiles = await globby(['**'], {
cwd: staticDir,
});
await Promise.all(
staticFiles.map(async source => {
const fromPath = path.resolve(staticDir, source);
const toPath = path.resolve(outDir, source);
return fs.copy(fromPath, toPath);
}),
);
}

/* Plugin lifecycle - postBuild */
await Promise.all(
Expand Down

0 comments on commit a32ce81

Please sign in to comment.