Improve auto adapter
This commit is contained in:
parent
b309d646a4
commit
dc2b3bd805
3 changed files with 54 additions and 16 deletions
|
@ -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,
|
||||
});
|
||||
|
|
|
@ -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",
|
||||
|
|
|
@ -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
|
||||
|
|
Reference in a new issue