summaryrefslogtreecommitdiff
path: root/packages/integrations/vercel/src/serverless/adapter.ts
diff options
context:
space:
mode:
authorGravatar Matthew Phillips <matthew@skypack.dev> 2022-11-14 13:42:35 -0500
committerGravatar GitHub <noreply@github.com> 2022-11-14 13:42:35 -0500
commitee750087ce360c54d349f160d84bbdafb0ec83b4 (patch)
treeb06edcbb4b0c46ba669d437e1f4578e60db17348 /packages/integrations/vercel/src/serverless/adapter.ts
parent993b58d5678f6c4aa6d766b1c2164b91935c9f10 (diff)
downloadastro-ee750087ce360c54d349f160d84bbdafb0ec83b4.tar.gz
astro-ee750087ce360c54d349f160d84bbdafb0ec83b4.tar.zst
astro-ee750087ce360c54d349f160d84bbdafb0ec83b4.zip
Fix usage of the Image component with the Vercel adapter (#5361)
* Revert "Revert "Allow image-pool to be used as its own Worker (#5317)" (#5360)" This reverts commit 20e60c6e0857f7b6938494df6027e8c1ad74cdc1. * Remove special image-pool.js moving around * Merge in assetIncludes * changeset * Copy to chunk folder in SSR too * Update tidy-shoes-yawn.md
Diffstat (limited to 'packages/integrations/vercel/src/serverless/adapter.ts')
-rw-r--r--packages/integrations/vercel/src/serverless/adapter.ts21
1 files changed, 20 insertions, 1 deletions
diff --git a/packages/integrations/vercel/src/serverless/adapter.ts b/packages/integrations/vercel/src/serverless/adapter.ts
index 3c7ba15de..3fff42f04 100644
--- a/packages/integrations/vercel/src/serverless/adapter.ts
+++ b/packages/integrations/vercel/src/serverless/adapter.ts
@@ -3,6 +3,8 @@ import type { AstroAdapter, AstroConfig, AstroIntegration } from 'astro';
import { getVercelOutput, removeDir, writeJson } from '../lib/fs.js';
import { copyDependenciesToFunction } from '../lib/nft.js';
import { getRedirects } from '../lib/redirects.js';
+import glob from 'fast-glob';
+import { pathToFileURL } from 'url';
const PACKAGE_NAME = '@astrojs/vercel/serverless';
@@ -66,11 +68,28 @@ export default function vercelServerless({
}
},
'astro:build:done': async ({ routes }) => {
+ // Merge any includes from `vite.assetsInclude
+ const inc = includeFiles?.map((file) => new URL(file, _config.root)) || [];
+ if(_config.vite.assetsInclude) {
+ const mergeGlobbedIncludes = (globPattern: unknown) => {
+ if(typeof globPattern === 'string') {
+ const entries = glob.sync(globPattern).map(p => pathToFileURL(p));
+ inc.push(...entries);
+ } else if(Array.isArray(globPattern)) {
+ for(const pattern of globPattern) {
+ mergeGlobbedIncludes(pattern);
+ }
+ }
+ };
+
+ mergeGlobbedIncludes(_config.vite.assetsInclude);
+ }
+
// Copy necessary files (e.g. node_modules/)
const { handler } = await copyDependenciesToFunction({
entry: new URL(serverEntry, buildTempFolder),
outDir: functionFolder,
- includeFiles: includeFiles?.map((file) => new URL(file, _config.root)) || [],
+ includeFiles: inc,
excludeFiles: excludeFiles?.map((file) => new URL(file, _config.root)) || [],
});