use vite plugin for env-config generation

This commit is contained in:
Lukas Hass 2022-01-31 16:56:50 +01:00
parent 5091e8d649
commit b83fc77183
No known key found for this signature in database
GPG Key ID: 7C8CEF72C4039178
5 changed files with 39 additions and 29 deletions

View File

@ -27,7 +27,6 @@
<meta name="msapplication-TileImage" content="static/images/favicons/ms-icon-144x144.png"> <meta name="msapplication-TileImage" content="static/images/favicons/ms-icon-144x144.png">
<meta name="theme-color" content="#000000"> <meta name="theme-color" content="#000000">
<script src="/env-config.js"></script>
<base href="/"> <base href="/">
<link href="https://unpkg.com/nes.css@2.3.0/css/nes.min.css" rel="stylesheet" /> <link href="https://unpkg.com/nes.css@2.3.0/css/nes.min.css" rel="stylesheet" />

View File

@ -4,6 +4,7 @@
"main": "index.js", "main": "index.js",
"license": "SEE LICENSE IN LICENSE.txt", "license": "SEE LICENSE IN LICENSE.txt",
"devDependencies": { "devDependencies": {
"@geprog/vite-plugin-env-config": "^3.0.0",
"@sveltejs/vite-plugin-svelte": "^1.0.0-next.36", "@sveltejs/vite-plugin-svelte": "^1.0.0-next.36",
"@tsconfig/svelte": "^1.0.10", "@tsconfig/svelte": "^1.0.10",
"@types/google-protobuf": "^3.7.3", "@types/google-protobuf": "^3.7.3",

View File

@ -1,27 +0,0 @@
window.env = {
SKIP_RENDER_OPTIMIZATIONS: '${SKIP_RENDER_OPTIMIZATIONS}',
DISABLE_NOTIFICATIONS: '${DISABLE_NOTIFICATIONS}',
PUSHER_URL: '${PUSHER_URL}',
UPLOADER_URL: '${UPLOADER_URL}',
ADMIN_URL: '${ADMIN_URL}',
CONTACT_URL: '${CONTACT_URL}',
PROFILE_URL: '${PROFILE_URL}',
ICON_URL: '${ICON_URL}',
DEBUG_MODE: '${DEBUG_MODE}',
STUN_SERVER: '${STUN_SERVER}',
TURN_SERVER: '${TURN_SERVER}',
TURN_USER: '${TURN_USER}',
TURN_PASSWORD: '${TURN_PASSWORD}',
JITSI_URL: '${JITSI_URL}',
JITSI_PRIVATE_MODE: '${JITSI_PRIVATE_MODE}',
START_ROOM_URL: '${START_ROOM_URL}',
MAX_USERNAME_LENGTH: '${MAX_USERNAME_LENGTH}',
MAX_PER_GROUP: '${MAX_PER_GROUP}',
DISPLAY_TERMS_OF_USE: '${DISPLAY_TERMS_OF_USE}',
POSTHOG_API_KEY: '${POSTHOG_API_KEY}',
POSTHOG_URL: '${POSTHOG_URL}',
NODE_ENV: '${NODE_ENV}',
DISABLE_ANONYMOUS: '${DISABLE_ANONYMOUS}',
OPID_LOGIN_SCREEN_PROVIDER: '${OPID_LOGIN_SCREEN_PROVIDER}',
FALLBACK_LOCALE: '${FALLBACK_LOCALE}',
};

View File

@ -1,6 +1,38 @@
import { defineConfig } from "vite"; import { defineConfig } from "vite";
import { svelte } from "@sveltejs/vite-plugin-svelte"; import { svelte } from "@sveltejs/vite-plugin-svelte";
import { envConfig } from "@geprog/vite-plugin-env-config";
export default defineConfig({ export default defineConfig({
plugins: [svelte({})], plugins: [
svelte({}),
envConfig({
variables: [
"SKIP_RENDER_OPTIMIZATIONS",
"DISABLE_NOTIFICATIONS",
"PUSHER_URL",
"UPLOADER_URL",
"ADMIN_URL",
"CONTACT_URL",
"PROFILE_URL",
"ICON_URL",
"DEBUG_MODE",
"STUN_SERVER",
"TURN_SERVER",
"TURN_USER",
"TURN_PASSWORD",
"JITSI_URL",
"JITSI_PRIVATE_MODE",
"START_ROOM_URL",
"MAX_USERNAME_LENGTH",
"MAX_PER_GROUP",
"DISPLAY_TERMS_OF_USE",
"POSTHOG_API_KEY",
"POSTHOG_URL",
"NODE_ENV",
"DISABLE_ANONYMOUS",
"OPID_LOGIN_SCREEN_PROVIDER",
"FALLBACK_LOCALE",
],
}),
],
}); });

View File

@ -93,6 +93,11 @@
dependencies: dependencies:
"@fortawesome/fontawesome-common-types" "^0.2.35" "@fortawesome/fontawesome-common-types" "^0.2.35"
"@geprog/vite-plugin-env-config@^3.0.0":
version "3.0.0"
resolved "https://registry.yarnpkg.com/@geprog/vite-plugin-env-config/-/vite-plugin-env-config-3.0.0.tgz#b16e57ad16429be7d73d19f13b5b529a78e7f9fa"
integrity sha512-ocIPodgIZAJm+h6As20IB8s5RLV85wvlnXNRFU2oI1owbBLqDjzSleY9+6Ey0abGSu0MNXlJQZL5ApSg6L5qCg==
"@humanwhocodes/config-array@^0.9.2": "@humanwhocodes/config-array@^0.9.2":
version "0.9.2" version "0.9.2"
resolved "https://registry.yarnpkg.com/@humanwhocodes/config-array/-/config-array-0.9.2.tgz#68be55c737023009dfc5fe245d51181bb6476914" resolved "https://registry.yarnpkg.com/@humanwhocodes/config-array/-/config-array-0.9.2.tgz#68be55c737023009dfc5fe245d51181bb6476914"