Simplify Astro config

This commit is contained in:
Nikita Karamov 2023-08-30 12:19:28 +02:00
parent ebb3bdd013
commit 4ee55fe77c
No known key found for this signature in database
GPG key ID: 41D6F71EE78E77CD
2 changed files with 20 additions and 14 deletions

View file

@ -8,36 +8,31 @@ 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 configMixin = {}; let adapterConfig = {};
if (process.env.VERCEL) { if (process.env.VERCEL) {
console.info("Using Vercel (serverless) adapter..."); console.info("Using Vercel (serverless) adapter...");
configMixin = { adapterConfig = {
output: "server",
adapter: vercel(), adapter: vercel(),
}; };
} else if (process.env.CF_PAGES) { } else if (process.env.CF_PAGES) {
console.info("Using Cloudflare adapter..."); console.info("Using Cloudflare adapter...");
configMixin = { adapterConfig = {
output: "server",
adapter: cloudflare(), adapter: cloudflare(),
}; };
} else if (process.env.NETLIFY) { } else if (process.env.NETLIFY) {
console.info("Using Netlify (Functions) adapter..."); console.info("Using Netlify (Functions) adapter...");
configMixin = { adapterConfig = {
output: "server",
adapter: netlify(), adapter: netlify(),
}; };
} else if (process.argv.includes("--s2f-use-deno")) { } else if (process.argv.includes("--s2f-use-deno")) {
console.info("Using Deno adapter..."); console.info("Using Deno adapter...");
configMixin = { adapterConfig = {
output: "server",
adapter: deno(), adapter: deno(),
}; };
} else { } else {
console.info("Using Node.js adapter..."); console.info("Using Node.js adapter...");
console.info("Run with '--s2f-use-deno' flag to use Deno"); console.info("Run with '--s2f-use-deno' flag to use Deno");
configMixin = { adapterConfig = {
output: "server",
adapter: node({ adapter: node({
mode: "standalone", mode: "standalone",
}), }),
@ -46,7 +41,18 @@ if (process.env.VERCEL) {
export default defineConfig({ export default defineConfig({
site: "https://s2f.kytta.dev", site: "https://s2f.kytta.dev",
...configMixin, redirects: {
"/api/toot": {
destination: "/api/share",
status: 308,
},
},
compressHTML: true,
output: "server",
...adapterConfig,
vite: { vite: {
plugins: [lightningcss()], plugins: [lightningcss()],
}, },

View file

@ -12,8 +12,8 @@
"private": true, "private": true,
"type": "module", "type": "module",
"scripts": { "scripts": {
"dev": "astro dev --host 127.0.0.1", "dev": "astro dev",
"start": "astro dev --host 127.0.0.1", "start": "astro dev",
"build": "astro build", "build": "astro build",
"build:icons": "bash ./script/build-icons", "build:icons": "bash ./script/build-icons",
"preview": "astro preview", "preview": "astro preview",