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