Skip to content

Commit

Permalink
check for api assets build output directory before copying for vercel…
Browse files Browse the repository at this point in the history
… adapter
  • Loading branch information
thescientist13 committed Oct 14, 2023
1 parent 3432617 commit e2d44b7
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 6 deletions.
2 changes: 1 addition & 1 deletion packages/cli/src/config/rollup.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -287,7 +287,7 @@ function greenwoodPatchSsrPagesEntryPointRuntimeImport() {

bundle[key].code = bundle[key].code.replace(/'___GWD_ENTRY_FILE_URL=(.*.)___'/, `new URL('./_${entryPathMatch}', import.meta.url)`);
} else {
console.warn(`Could not find entry path match for bundle => ${ley}`);
console.warn(`Could not find entry path match for bundle => ${key}`);
}
}
});
Expand Down
13 changes: 8 additions & 5 deletions packages/plugin-adapter-vercel/src/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -144,11 +144,14 @@ async function vercelAdapter(compilation) {
new URL(`./${id}.js`, outputRoot),
{ recursive: true }
);
await fs.cp(
new URL('./api/assets/', outputDir),
new URL('./assets/', outputRoot),
{ recursive: true }
);

if (await checkResourceExists(new URL('./api/assets/', outputDir))) {
await fs.cp(
new URL('./api/assets/', outputDir),
new URL('./assets/', outputRoot),
{ recursive: true }
);
}

const ssrApiAssets = (await fs.readdir(new URL('./api/', outputDir)))
.filter(file => new RegExp(/^[\w][\w-]*\.[a-zA-Z0-9]{4,20}\.[\w]{2,4}$/).test(path.basename(file)));
Expand Down

0 comments on commit e2d44b7

Please sign in to comment.