0
Fork 0
mirror of https://github.com/withastro/astro.git synced 2025-03-10 23:01:26 -05:00

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 20e60c6e08.

* Remove special image-pool.js moving around

* Merge in assetIncludes

* changeset

* Copy to chunk folder in SSR too

* Update tidy-shoes-yawn.md
This commit is contained in:
Matthew Phillips 2022-11-14 13:42:35 -05:00 committed by GitHub
parent 5bf07a9c94
commit bf733125bc
2 changed files with 22 additions and 2 deletions

View file

@ -45,7 +45,8 @@
},
"dependencies": {
"@astrojs/webapi": "^1.1.1",
"@vercel/nft": "^0.22.1"
"@vercel/nft": "^0.22.1",
"fast-glob": "^3.2.11"
},
"devDependencies": {
"astro": "workspace:*",

View file

@ -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)) || [],
});