From dc2b3bd805841fd484da0d5c40cd58c71d03b827 Mon Sep 17 00:00:00 2001 From: Nikita Karamov Date: Sat, 26 Aug 2023 15:27:20 +0200 Subject: [PATCH] Improve auto adapter --- astro.config.mjs | 57 ++++++++++++++++++++++++++++++++++-------------- package.json | 1 + pnpm-lock.yaml | 12 ++++++++++ 3 files changed, 54 insertions(+), 16 deletions(-) diff --git a/astro.config.mjs b/astro.config.mjs index 3e987ee..dcafac6 100644 --- a/astro.config.mjs +++ b/astro.config.mjs @@ -1,29 +1,54 @@ import { defineConfig } from "astro/config"; import cloudflare from "@astrojs/cloudflare"; -import { netlifyFunctions } from "@astrojs/netlify"; +import deno from "@astrojs/deno"; +import netlify from "@astrojs/netlify"; import node from "@astrojs/node"; import vercel from "@astrojs/vercel/serverless"; -let astroAdapter; -if (process.env.CF_PAGES) { - console.debug("Using Cloudflare adapter"); - astroAdapter = cloudflare(); -} else if (process.env.VERCEL) { - console.debug("Using Vercel adapter"); - astroAdapter = vercel(); +let configMixin = {}; +if (process.env.VERCEL) { + console.info("Using Vercel (serverless) adapter..."); + configMixin = { + output: "server", + adapter: vercel(), + build: { + split: true, + }, + }; +} else if (process.env.CF_PAGES) { + console.info("Using Cloudflare adapter..."); + configMixin = { + output: "server", + adapter: cloudflare(), + }; } else if (process.env.NETLIFY) { - console.debug("Using Netlify adapter"); - astroAdapter = netlifyFunctions(); + console.info("Using Netlify (Functions) adapter..."); + configMixin = { + output: "server", + adapter: netlify(), + build: { + split: true, + }, + }; +} else if (process.argv.includes("--s2f-use-deno")) { + console.info("Using Deno adapter..."); + configMixin = { + output: "server", + adapter: deno(), + }; } else { - console.debug("Using Node.js adapter"); - astroAdapter = node({ - mode: "standalone", - }); + console.info("Using Node.js adapter..."); + console.info("Run with '--s2f-use-deno' flag to use Deno"); + configMixin = { + output: "server", + adapter: node({ + mode: "standalone", + }), + }; } export default defineConfig({ site: "https://s2f.kytta.dev", - adapter: astroAdapter, - output: "server", + ...configMixin, }); diff --git a/package.json b/package.json index 4333377..f08c579 100644 --- a/package.json +++ b/package.json @@ -22,6 +22,7 @@ "browserslist": "cover 95%, last 2 versions, Firefox ESR, not dead", "dependencies": { "@astrojs/cloudflare": "^6.8.1", + "@astrojs/deno": "^4.3.0", "@astrojs/netlify": "^2.6.0", "@astrojs/node": "^5.3.6", "@astrojs/vercel": "^3.8.2", diff --git a/pnpm-lock.yaml b/pnpm-lock.yaml index abc8e00..1f9e51e 100644 --- a/pnpm-lock.yaml +++ b/pnpm-lock.yaml @@ -8,6 +8,9 @@ dependencies: '@astrojs/cloudflare': specifier: ^6.8.1 version: 6.8.1(astro@2.10.14) + '@astrojs/deno': + specifier: ^4.3.0 + version: 4.3.0(astro@2.10.14) '@astrojs/netlify': specifier: ^2.6.0 version: 2.6.0(astro@2.10.14) @@ -120,6 +123,15 @@ packages: resolution: {integrity: sha512-DfBR7Cf+tOgQ4n7TIgTtU5x5SEA/08DNshpEPcT+91A0KbBlmUOYMBM/O6qAaHkmVo1KIoXQYhAmfdTT1zx9PQ==} dev: true + /@astrojs/deno@4.3.0(astro@2.10.14): + resolution: {integrity: sha512-bGBhdvlJ6XhnCGNNM6T0uTRBI1/DK7ZxtlDPoCeYbIK4u+A+NN7ixe585DjvtvfHOuoJinVpAMGmpfdyadlB8Q==} + peerDependencies: + astro: ^2.9.3 + dependencies: + astro: 2.10.14(@types/node@18.17.11)(sass@1.66.1)(sharp@0.32.5) + esbuild: 0.15.18 + dev: false + /@astrojs/internal-helpers@0.1.2: resolution: {integrity: sha512-YXLk1CUDdC9P5bjFZcGjz+cE/ZDceXObDTXn/GCID4r8LjThuexxi+dlJqukmUpkSItzQqgzfWnrPLxSFPejdA==} dev: false