Skip to content

Commit

Permalink
chore: import.meta.env not available in config files
Browse files Browse the repository at this point in the history
  • Loading branch information
techfg committed Apr 6, 2024
1 parent f55548e commit ece26c8
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 9 deletions.
7 changes: 5 additions & 2 deletions site/astro.config.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,11 @@ import starlight from '@astrojs/starlight';

// https://astro.build/config
export default defineConfig({
site: import.meta.env.SITE_URL || 'https://jamietre.github.io',
base: import.meta.env.BASE_PATH || 'ImageMapster',
// astro hasn't made import.meta.env available yet so we need
// to use process to obtain variables
// https://github.com/withastro/astro/issues/3897#issuecomment-1181381500
site: process.env.SITE_URL || 'https://jamietre.github.io',
base: process.env.BASE_PATH || 'ImageMapster',
integrations: [
starlight({
title: 'My Docs',
Expand Down
14 changes: 7 additions & 7 deletions site/src/env.d.ts
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
/// <reference path="../.astro/types.d.ts" />
/// <reference types="astro/client" />

interface ImportMetaEnv {
readonly SITE_URL: string;
readonly BASE_PATH: string;
}

interface ImportMeta {
readonly env: ImportMetaEnv;
declare global {
namespace NodeJS {
interface ProcessEnv {
readonly SITE_URL: string;
readonly BASE_PATH: string;
}
}
}

0 comments on commit ece26c8

Please sign in to comment.