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

Use .mjs extension when building for netlify edge and vercel serverless (#6317)

This commit is contained in:
Bjorn Lu 2023-02-21 22:14:47 +08:00 committed by GitHub
parent e252151353
commit 9821312d0b
5 changed files with 47 additions and 1 deletions

View file

@ -43,7 +43,7 @@ export default function vercelServerless({
updateConfig({
outDir,
build: {
serverEntry: 'entry.js',
serverEntry: 'entry.mjs',
client: new URL('./static/', outDir),
server: new URL('./dist/', config.root),
},

View file

@ -0,0 +1,7 @@
import { defineConfig } from 'astro/config';
import vercel from '@astrojs/vercel/serverless';
export default defineConfig({
adapter: vercel(),
output: 'server'
});

View file

@ -0,0 +1,9 @@
{
"name": "@test/astro-vercel-serverless-prerender",
"version": "0.0.0",
"private": true,
"dependencies": {
"@astrojs/vercel": "workspace:*",
"astro": "workspace:*"
}
}

View file

@ -0,0 +1,12 @@
---
export const prerender = true
---
<html>
<head>
<title>testing</title>
</head>
<body>
<h1>testing</h1>
</body>
</html>

View file

@ -0,0 +1,18 @@
import { loadFixture } from './test-utils.js';
import { expect } from 'chai';
describe('Serverless prerender', () => {
/** @type {import('./test-utils').Fixture} */
let fixture;
before(async () => {
fixture = await loadFixture({
root: './fixtures/serverless-prerender/',
});
});
it('build successful', async () => {
await fixture.build();
expect(fixture.readFile('/static/index.html')).to.be.ok;
});
});