fix(v2): should be able to build even if static folder doesnt exist (#1479)

This commit is contained in:
Endi 2019-05-17 18:15:48 +07:00 committed by GitHub
parent 0e5cac94cb
commit 05ba7d835d
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -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(