2022-03-30 07:42:19 -05:00
|
|
|
import type { AstroAdapter, AstroIntegration } from 'astro';
|
|
|
|
|
|
|
|
interface Options {
|
|
|
|
port?: number;
|
|
|
|
hostname?: string;
|
|
|
|
}
|
|
|
|
|
|
|
|
export function getAdapter(args?: Options): AstroAdapter {
|
|
|
|
return {
|
|
|
|
name: '@astrojs/deno',
|
|
|
|
serverEntrypoint: '@astrojs/deno/server.js',
|
|
|
|
args: args ?? {},
|
2022-04-15 16:01:33 -05:00
|
|
|
exports: ['stop', 'handle', 'start', 'running'],
|
2022-03-30 07:42:19 -05:00
|
|
|
};
|
|
|
|
}
|
|
|
|
|
|
|
|
export default function createIntegration(args?: Options): AstroIntegration {
|
|
|
|
return {
|
|
|
|
name: '@astrojs/deno',
|
|
|
|
hooks: {
|
|
|
|
'astro:config:done': ({ setAdapter }) => {
|
|
|
|
setAdapter(getAdapter(args));
|
|
|
|
},
|
|
|
|
'astro:build:setup': ({ vite, target }) => {
|
2022-03-30 07:43:13 -05:00
|
|
|
if (target === 'server') {
|
2022-03-30 07:42:19 -05:00
|
|
|
vite.ssr = {
|
2022-03-30 07:43:13 -05:00
|
|
|
noExternal: true,
|
2022-03-30 07:42:19 -05:00
|
|
|
};
|
|
|
|
}
|
2022-03-30 07:43:13 -05:00
|
|
|
},
|
2022-03-30 07:42:19 -05:00
|
|
|
},
|
|
|
|
};
|
|
|
|
}
|