mirror of
https://github.com/withastro/astro.git
synced 2025-03-10 23:01:26 -05:00
fix(vercel): handle integration static assets in non-static sites (#516)
* fix: arrange assets for server output too * Changeset * Format
This commit is contained in:
parent
a369ecc9ce
commit
ef430a4238
2 changed files with 16 additions and 14 deletions
|
@ -220,11 +220,12 @@ export default function vercelAdapter({
|
||||||
name: 'astro:copy-vercel-output',
|
name: 'astro:copy-vercel-output',
|
||||||
hooks: {
|
hooks: {
|
||||||
'astro:build:done': async () => {
|
'astro:build:done': async () => {
|
||||||
if (_buildOutput === 'static') {
|
logger.info('Copying static files to .vercel/output/static');
|
||||||
cpSync(_config.outDir, new URL('./.vercel/output/static/', _config.root), {
|
const staticDir =
|
||||||
|
_buildOutput === 'static' ? _config.outDir : _config.build.client;
|
||||||
|
cpSync(staticDir, new URL('./.vercel/output/static/', _config.root), {
|
||||||
recursive: true,
|
recursive: true,
|
||||||
});
|
});
|
||||||
}
|
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
|
@ -329,9 +330,6 @@ export default function vercelAdapter({
|
||||||
mkdirSync(new URL('./.vercel/output/server/', _config.root));
|
mkdirSync(new URL('./.vercel/output/server/', _config.root));
|
||||||
|
|
||||||
if (_buildOutput !== 'static') {
|
if (_buildOutput !== 'static') {
|
||||||
cpSync(_config.build.client, new URL('./.vercel/output/static/', _config.root), {
|
|
||||||
recursive: true,
|
|
||||||
});
|
|
||||||
cpSync(_config.build.server, new URL('./.vercel/output/_functions/', _config.root), {
|
cpSync(_config.build.server, new URL('./.vercel/output/_functions/', _config.root), {
|
||||||
recursive: true,
|
recursive: true,
|
||||||
});
|
});
|
||||||
|
|
|
@ -3,17 +3,21 @@ import { before, describe, it } from 'node:test';
|
||||||
import { loadFixture } from './test-utils.js';
|
import { loadFixture } from './test-utils.js';
|
||||||
|
|
||||||
describe('Assets generated by integrations', () => {
|
describe('Assets generated by integrations', () => {
|
||||||
/** @type {import('./test-utils.js').Fixture} */
|
it('moves static assets generated by integrations to the correct location: static output', async () => {
|
||||||
let fixture;
|
const fixture = await loadFixture({
|
||||||
|
|
||||||
before(async () => {
|
|
||||||
fixture = await loadFixture({
|
|
||||||
root: './fixtures/integration-assets/',
|
root: './fixtures/integration-assets/',
|
||||||
});
|
});
|
||||||
await fixture.build();
|
await fixture.build();
|
||||||
|
const sitemap = await fixture.readFile('../.vercel/output/static/sitemap-index.xml');
|
||||||
|
assert(sitemap.includes('<sitemapindex xmlns="http://www.sitemaps.org/schemas/sitemap/0.9">'));
|
||||||
});
|
});
|
||||||
|
|
||||||
it('moves static assets generated by integrations to the correct location', async () => {
|
it('moves static assets generated by integrations to the correct location: server output', async () => {
|
||||||
|
const fixture = await loadFixture({
|
||||||
|
root: './fixtures/integration-assets/',
|
||||||
|
output: 'server',
|
||||||
|
});
|
||||||
|
await fixture.build();
|
||||||
const sitemap = await fixture.readFile('../.vercel/output/static/sitemap-index.xml');
|
const sitemap = await fixture.readFile('../.vercel/output/static/sitemap-index.xml');
|
||||||
assert(sitemap.includes('<sitemapindex xmlns="http://www.sitemaps.org/schemas/sitemap/0.9">'));
|
assert(sitemap.includes('<sitemapindex xmlns="http://www.sitemaps.org/schemas/sitemap/0.9">'));
|
||||||
});
|
});
|
||||||
|
|
Loading…
Add table
Reference in a new issue