mirror of
https://github.com/facebook/docusaurus.git
synced 2025-08-04 01:09:20 +02:00
fix(v2): should be able to build even if static folder doesnt exist (#1479)
This commit is contained in:
parent
0e5cac94cb
commit
05ba7d835d
1 changed files with 12 additions and 10 deletions
|
@ -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(
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue