0
Fork 0
mirror of https://github.com/withastro/astro.git synced 2025-03-24 23:21:57 -05:00
astro/packages/astro/test/test-adapter.js
Matthew Phillips 4ac0d5d4e7
Support the Markdown component in SSR (#3036)
* Support the Markdown component in SSR

* Adds a changeset

* Support runtime markdown in Node.js

* Remove option from test adapter
2022-04-14 09:51:53 -04:00

43 lines
1,009 B
JavaScript

import { viteID } from '../dist/core/util.js';
/**
*
* @returns {import('../src/@types/astro').AstroIntegration}
*/
export default function () {
return {
name: 'my-ssr-adapter',
hooks: {
'astro:config:setup': ({ updateConfig }) => {
updateConfig({
vite: {
plugins: [
{
resolveId(id) {
if (id === '@my-ssr') {
return id;
} else if (id === 'astro/app') {
const id = viteID(new URL('../dist/core/app/index.js', import.meta.url));
return id;
}
},
load(id) {
if (id === '@my-ssr') {
return `import { App } from 'astro/app';export function createExports(manifest) { return { manifest, createApp: () => new App(manifest) }; }`;
}
},
},
],
},
});
},
'astro:config:done': ({ setAdapter }) => {
setAdapter({
name: 'my-ssr-adapter',
serverEntrypoint: '@my-ssr',
exports: ['manifest', 'createApp'],
});
}
},
};
}