[ci] format
This commit is contained in:
parent
154af8f5ea
commit
7ae6e89292
3 changed files with 10 additions and 14 deletions
|
@ -228,8 +228,8 @@ export default defineConfig({
|
||||||
output: 'server',
|
output: 'server',
|
||||||
adapter: vercel(),
|
adapter: vercel(),
|
||||||
build: {
|
build: {
|
||||||
split: true
|
split: true,
|
||||||
}
|
},
|
||||||
});
|
});
|
||||||
```
|
```
|
||||||
|
|
||||||
|
|
|
@ -1,6 +1,7 @@
|
||||||
import type { AstroAdapter, AstroConfig, AstroIntegration, RouteData } from 'astro';
|
import type { AstroAdapter, AstroConfig, AstroIntegration, RouteData } from 'astro';
|
||||||
|
|
||||||
import glob from 'fast-glob';
|
import glob from 'fast-glob';
|
||||||
|
import { basename } from 'node:path';
|
||||||
import { pathToFileURL } from 'url';
|
import { pathToFileURL } from 'url';
|
||||||
import {
|
import {
|
||||||
defaultImageConfig,
|
defaultImageConfig,
|
||||||
|
@ -12,7 +13,6 @@ import { exposeEnv } from '../lib/env.js';
|
||||||
import { getVercelOutput, removeDir, writeJson } from '../lib/fs.js';
|
import { getVercelOutput, removeDir, writeJson } from '../lib/fs.js';
|
||||||
import { copyDependenciesToFunction } from '../lib/nft.js';
|
import { copyDependenciesToFunction } from '../lib/nft.js';
|
||||||
import { getRedirects } from '../lib/redirects.js';
|
import { getRedirects } from '../lib/redirects.js';
|
||||||
import { basename } from 'node:path';
|
|
||||||
|
|
||||||
const PACKAGE_NAME = '@astrojs/vercel/serverless';
|
const PACKAGE_NAME = '@astrojs/vercel/serverless';
|
||||||
|
|
||||||
|
@ -130,13 +130,13 @@ export default function vercelServerless({
|
||||||
const routeDefinitions: { src: string; dest: string }[] = [];
|
const routeDefinitions: { src: string; dest: string }[] = [];
|
||||||
|
|
||||||
// Multiple entrypoint support
|
// Multiple entrypoint support
|
||||||
if(_entryPoints.size) {
|
if (_entryPoints.size) {
|
||||||
for(const [route, entryFile] of _entryPoints) {
|
for (const [route, entryFile] of _entryPoints) {
|
||||||
const func = basename(entryFile.toString()).replace(/\.mjs$/, '');
|
const func = basename(entryFile.toString()).replace(/\.mjs$/, '');
|
||||||
await createFunctionFolder(func, entryFile, inc);
|
await createFunctionFolder(func, entryFile, inc);
|
||||||
routeDefinitions.push({
|
routeDefinitions.push({
|
||||||
src: route.pattern.source,
|
src: route.pattern.source,
|
||||||
dest: func
|
dest: func,
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
|
@ -148,11 +148,7 @@ export default function vercelServerless({
|
||||||
// https://vercel.com/docs/build-output-api/v3#build-output-configuration
|
// https://vercel.com/docs/build-output-api/v3#build-output-configuration
|
||||||
await writeJson(new URL(`./config.json`, _config.outDir), {
|
await writeJson(new URL(`./config.json`, _config.outDir), {
|
||||||
version: 3,
|
version: 3,
|
||||||
routes: [
|
routes: [...getRedirects(routes, _config), { handle: 'filesystem' }, ...routeDefinitions],
|
||||||
...getRedirects(routes, _config),
|
|
||||||
{ handle: 'filesystem' },
|
|
||||||
...routeDefinitions
|
|
||||||
],
|
|
||||||
...(imageService || imagesConfig
|
...(imageService || imagesConfig
|
||||||
? { images: imagesConfig ? imagesConfig : defaultImageConfig }
|
? { images: imagesConfig ? imagesConfig : defaultImageConfig }
|
||||||
: {}),
|
: {}),
|
||||||
|
|
|
@ -11,13 +11,13 @@ describe('build: split', () => {
|
||||||
output: 'server',
|
output: 'server',
|
||||||
build: {
|
build: {
|
||||||
split: true,
|
split: true,
|
||||||
}
|
},
|
||||||
});
|
});
|
||||||
await fixture.build();
|
await fixture.build();
|
||||||
});
|
});
|
||||||
|
|
||||||
it('creates separate functions for each page', async () => {
|
it('creates separate functions for each page', async () => {
|
||||||
const files = await fixture.readdir('../.vercel/output/functions/')
|
const files = await fixture.readdir('../.vercel/output/functions/');
|
||||||
expect(files.length).to.equal(2);
|
expect(files.length).to.equal(2);
|
||||||
});
|
});
|
||||||
|
|
||||||
|
@ -25,5 +25,5 @@ describe('build: split', () => {
|
||||||
const json = await fixture.readFile('../.vercel/output/config.json');
|
const json = await fixture.readFile('../.vercel/output/config.json');
|
||||||
const config = JSON.parse(json);
|
const config = JSON.parse(json);
|
||||||
expect(config.routes).to.have.a.lengthOf(3);
|
expect(config.routes).to.have.a.lengthOf(3);
|
||||||
})
|
});
|
||||||
});
|
});
|
||||||
|
|
Loading…
Reference in a new issue