-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
FIX: Vite envs not being injected (#218)
* fix bug where variables arent injected correctly * . * satisfy lint * . * changed dockerfile * ignore scripts * lint * fix
- Loading branch information
Showing
10 changed files
with
859 additions
and
4,182 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
DAPLA_TEAM_API_URL= | ||
DAPLA_CTRL_ADMIN_GROUPS= | ||
DAPLA_CTRL_DOCUMENTATION_URL= | ||
DAPLA_CTRL_DAPLA_START_URL= |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1 +1,37 @@ | ||
/// <reference types="vite/client" /> | ||
/// <reference types="vite-envs/client" /> | ||
|
||
type ImportMetaEnv = { | ||
// Auto-generated by `npx vite-envs update-types` and hot-reloaded by the `vite-env` plugin | ||
BASE_URL: string | ||
MODE: string | ||
DEV: boolean | ||
PROD: boolean | ||
BUILD_TIME: number | ||
VERSION: string | ||
DAPLA_TEAM_API_URL: string | ||
DAPLA_CTRL_ADMIN_GROUPS: string | ||
DAPLA_CTRL_DOCUMENTATION_URL: string | ||
DAPLA_CTRL_DAPLA_START_URL: string | ||
// @user-defined-start | ||
/* | ||
* Here you can define your own special variables | ||
* that would be available on `import.meta.env` but | ||
* that vite-envs does not know about. | ||
* This section will be preserved thanks to the special comments. | ||
* Example: | ||
*/ | ||
SSR: boolean | ||
// @user-defined-end | ||
} | ||
|
||
interface ImportMeta { | ||
// Auto-generated by `npx vite-envs update-types` | ||
|
||
url: string | ||
|
||
readonly hot?: import('vite-envs/types/hot').ViteHotContext | ||
|
||
readonly env: ImportMetaEnv | ||
|
||
glob: import('vite-envs/types/importGlob').ImportGlobFunction | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,7 +1,32 @@ | ||
import { defineConfig } from 'vite' | ||
import react from '@vitejs/plugin-react-swc' | ||
import { viteEnvs } from 'vite-envs' | ||
|
||
// https://vitejs.dev/config/ | ||
export default defineConfig({ | ||
plugins: [react()], | ||
plugins: [ | ||
react(), | ||
viteEnvs({ | ||
declarationFile: '.env', | ||
computedEnv: async ({ resolvedConfig }) => { | ||
const path = await import('path') | ||
const fs = await import('fs/promises') | ||
|
||
const packageJson = JSON.parse(await fs.readFile(path.join(resolvedConfig.root, 'package.json'), 'utf-8')) | ||
|
||
/* | ||
* Here you can define any arbitrary value they will be available | ||
* in `import.meta.env` and it's type definitions. | ||
* You can also compute defaults for variable declared in `.env` files. | ||
*/ | ||
return { | ||
BUILD_TIME: Date.now(), | ||
VERSION: packageJson.version, | ||
} | ||
}, | ||
}), | ||
], | ||
build: { | ||
sourcemap: true, | ||
}, | ||
}) |