From 002e64f9db9cff8933c2f82e995f5be0156f2a6b Mon Sep 17 00:00:00 2001 From: VaiTon Date: Mon, 18 Sep 2023 11:13:14 +0200 Subject: [PATCH] build: add node adapter to build config --- svelte.config.js | 23 ++++++++++++++++++----- 1 file changed, 18 insertions(+), 5 deletions(-) diff --git a/svelte.config.js b/svelte.config.js index 7785acd0..b20ad413 100644 --- a/svelte.config.js +++ b/svelte.config.js @@ -1,10 +1,27 @@ import staticAdapter from '@sveltejs/adapter-static'; import vercelAdapter from '@sveltejs/adapter-vercel'; +import nodeAdapter from "@sveltejs/adapter-node"; + import { vitePreprocess } from '@sveltejs/kit/vite'; /** @type {import('@sveltejs/kit').Config} */ const BASE_PATH = process.env.BASE_PATH || ''; const GITHUB_PAGES = process.env.GITHUB_ACTIONS === 'true'; +const CSUNIBO_DEPLOY = process.env.CSUNIBO_DEPLOY === 'true'; + +/** + * + * @returns {import('@sveltejs/kit').Adapter} + */ +function chooseAdapter() { + if (GITHUB_PAGES) { + return staticAdapter({ fallback: '404.html' }); + } else if (CSUNIBO_DEPLOY) { + return nodeAdapter(); + } else { + return vercelAdapter(); + } +} const config = { // Consult https://kit.svelte.dev/docs/integrations#preprocessors @@ -15,11 +32,7 @@ const config = { // adapter-auto only supports some environments, see https://kit.svelte.dev/docs/adapter-auto for a list. // If your environment is not supported or you settled on a specific environment, switch out the adapter. // See https://kit.svelte.dev/docs/adapters for more information about adapters. - adapter: GITHUB_PAGES - ? staticAdapter({ - fallback: '404.html' - }) - : vercelAdapter(), + adapter: chooseAdapter(), paths: { base: BASE_PATH }