Improve auto adapter

This commit is contained in:
Nikita Karamov 2023-08-26 15:27:20 +02:00
parent b309d646a4
commit dc2b3bd805
No known key found for this signature in database
GPG key ID: 41D6F71EE78E77CD
3 changed files with 54 additions and 16 deletions

View file

@ -1,29 +1,54 @@
import { defineConfig } from "astro/config"; import { defineConfig } from "astro/config";
import cloudflare from "@astrojs/cloudflare"; 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 node from "@astrojs/node";
import vercel from "@astrojs/vercel/serverless"; import vercel from "@astrojs/vercel/serverless";
let astroAdapter; let configMixin = {};
if (process.env.CF_PAGES) { if (process.env.VERCEL) {
console.debug("Using Cloudflare adapter"); console.info("Using Vercel (serverless) adapter...");
astroAdapter = cloudflare(); configMixin = {
} else if (process.env.VERCEL) { output: "server",
console.debug("Using Vercel adapter"); adapter: vercel(),
astroAdapter = 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) { } else if (process.env.NETLIFY) {
console.debug("Using Netlify adapter"); console.info("Using Netlify (Functions) adapter...");
astroAdapter = netlifyFunctions(); 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 { } else {
console.debug("Using Node.js adapter"); console.info("Using Node.js adapter...");
astroAdapter = node({ console.info("Run with '--s2f-use-deno' flag to use Deno");
mode: "standalone", configMixin = {
}); output: "server",
adapter: node({
mode: "standalone",
}),
};
} }
export default defineConfig({ export default defineConfig({
site: "https://s2f.kytta.dev", site: "https://s2f.kytta.dev",
adapter: astroAdapter, ...configMixin,
output: "server",
}); });

View file

@ -22,6 +22,7 @@
"browserslist": "cover 95%, last 2 versions, Firefox ESR, not dead", "browserslist": "cover 95%, last 2 versions, Firefox ESR, not dead",
"dependencies": { "dependencies": {
"@astrojs/cloudflare": "^6.8.1", "@astrojs/cloudflare": "^6.8.1",
"@astrojs/deno": "^4.3.0",
"@astrojs/netlify": "^2.6.0", "@astrojs/netlify": "^2.6.0",
"@astrojs/node": "^5.3.6", "@astrojs/node": "^5.3.6",
"@astrojs/vercel": "^3.8.2", "@astrojs/vercel": "^3.8.2",

View file

@ -8,6 +8,9 @@ dependencies:
'@astrojs/cloudflare': '@astrojs/cloudflare':
specifier: ^6.8.1 specifier: ^6.8.1
version: 6.8.1(astro@2.10.14) version: 6.8.1(astro@2.10.14)
'@astrojs/deno':
specifier: ^4.3.0
version: 4.3.0(astro@2.10.14)
'@astrojs/netlify': '@astrojs/netlify':
specifier: ^2.6.0 specifier: ^2.6.0
version: 2.6.0(astro@2.10.14) version: 2.6.0(astro@2.10.14)
@ -120,6 +123,15 @@ packages:
resolution: {integrity: sha512-DfBR7Cf+tOgQ4n7TIgTtU5x5SEA/08DNshpEPcT+91A0KbBlmUOYMBM/O6qAaHkmVo1KIoXQYhAmfdTT1zx9PQ==} resolution: {integrity: sha512-DfBR7Cf+tOgQ4n7TIgTtU5x5SEA/08DNshpEPcT+91A0KbBlmUOYMBM/O6qAaHkmVo1KIoXQYhAmfdTT1zx9PQ==}
dev: true 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: /@astrojs/internal-helpers@0.1.2:
resolution: {integrity: sha512-YXLk1CUDdC9P5bjFZcGjz+cE/ZDceXObDTXn/GCID4r8LjThuexxi+dlJqukmUpkSItzQqgzfWnrPLxSFPejdA==} resolution: {integrity: sha512-YXLk1CUDdC9P5bjFZcGjz+cE/ZDceXObDTXn/GCID4r8LjThuexxi+dlJqukmUpkSItzQqgzfWnrPLxSFPejdA==}
dev: false dev: false