diff --git a/frontend/.gitignore b/frontend/.gitignore index 973403058f..889aa94039 100644 --- a/frontend/.gitignore +++ b/frontend/.gitignore @@ -8,7 +8,6 @@ selenium-debug.log # local env files .env.local .env.*.local -public/environment.js # Auto-generated files public/twemoji/ diff --git a/frontend/docker-setup.sh b/frontend/docker-setup.sh index 1f73e4f9be..c38e726a1f 100755 --- a/frontend/docker-setup.sh +++ b/frontend/docker-setup.sh @@ -1,13 +1,6 @@ #!/bin/bash set -euo pipefail -BASEDIR=$(dirname "$0") -ENV_FILE=$BASEDIR"/public/environment.js" - -if [ ! -f "$ENV_FILE" ]; then - cp $BASEDIR/public/environment.docker.dist "$ENV_FILE" -fi - if [ "$CI" = 'true' ] ; then npm ci --verbose npm run build diff --git a/frontend/index.html b/frontend/index.html index a7717ba3a0..23f9cadfe8 100644 --- a/frontend/index.html +++ b/frontend/index.html @@ -55,47 +55,6 @@
- diff --git a/frontend/public/environment.dist b/frontend/public/environment.dist deleted file mode 100644 index c05e4f616d..0000000000 --- a/frontend/public/environment.dist +++ /dev/null @@ -1,13 +0,0 @@ -window.environment = { - API_ROOT_URL: '/api', - COOKIE_PREFIX: 'localhost_', - PRINT_URL: '/print', - SENTRY_FRONTEND_DSN: null, - SENTRY_ENVIRONMENT: "local", - DEPLOYMENT_TIME: '', - VERSION: '', - VERSION_LINK_TEMPLATE: 'https://github.com/ecamp/ecamp3/commit/{version}', - TERMS_OF_SERVICE_LINK_TEMPLATE: 'https://ecamp3.ch/{lang}/tos', - FEATURE_DEVELOPER: true, - LOGIN_INFO_TEXT_KEY: 'dev' -} diff --git a/frontend/public/environment.docker.dist b/frontend/public/environment.docker.dist deleted file mode 100644 index c05e4f616d..0000000000 --- a/frontend/public/environment.docker.dist +++ /dev/null @@ -1,13 +0,0 @@ -window.environment = { - API_ROOT_URL: '/api', - COOKIE_PREFIX: 'localhost_', - PRINT_URL: '/print', - SENTRY_FRONTEND_DSN: null, - SENTRY_ENVIRONMENT: "local", - DEPLOYMENT_TIME: '', - VERSION: '', - VERSION_LINK_TEMPLATE: 'https://github.com/ecamp/ecamp3/commit/{version}', - TERMS_OF_SERVICE_LINK_TEMPLATE: 'https://ecamp3.ch/{lang}/tos', - FEATURE_DEVELOPER: true, - LOGIN_INFO_TEXT_KEY: 'dev' -} diff --git a/frontend/public/environment.js b/frontend/public/environment.js new file mode 100644 index 0000000000..47b91ee3e6 --- /dev/null +++ b/frontend/public/environment.js @@ -0,0 +1,5 @@ +/** + * This is a placeholder. + * In production, this file is filled with the values for window.environment. + * In development, window.environment is filled in src/dev-environment.js + */ diff --git a/frontend/src/App.vue b/frontend/src/App.vue index c676f5d406..653b58882c 100644 --- a/frontend/src/App.vue +++ b/frontend/src/App.vue @@ -28,28 +28,29 @@ import LanguageSwitcher from '@/components/layout/LanguageSwitcher.vue' import VueI18n from '@/plugins/i18n' import { parseTemplate } from 'url-template' +import { getEnv } from '@/environment.js' export default { name: 'App', components: { LanguageSwitcher }, computed: { deploymentTime() { - const timestamp = window.environment.DEPLOYMENT_TIME + const timestamp = getEnv().DEPLOYMENT_TIME const dateTime = timestamp ? this.$date.unix(timestamp) : this.$date() return dateTime.format(this.$tc('global.datetime.dateTimeLong')) }, version() { - return window.environment.VERSION || '' + return getEnv().VERSION || '' }, versionLink() { return ( - parseTemplate(window.environment.VERSION_LINK_TEMPLATE).expand({ + parseTemplate(getEnv().VERSION_LINK_TEMPLATE).expand({ version: this.version, }) || '#' ) }, isDev() { - return window.environment.FEATURE_DEVELOPER ?? false + return getEnv().FEATURE_DEVELOPER ?? false }, }, created() { diff --git a/frontend/src/components/print/PrintConfigurator.vue b/frontend/src/components/print/PrintConfigurator.vue index 3b8f833598..f75a9ca0db 100644 --- a/frontend/src/components/print/PrintConfigurator.vue +++ b/frontend/src/components/print/PrintConfigurator.vue @@ -107,6 +107,7 @@ import PagesOverview from './configurator/PagesOverview.vue' import PagesConfig from './configurator/PagesConfig.vue' import DownloadNuxtPdfButton from '@/components/print/print-nuxt/DownloadNuxtPdfButton.vue' import DownloadClientPdfButton from '@/components/print/print-client/DownloadClientPdfButton.vue' +import { getEnv } from '@/environment.js' export default { name: 'PrintConfigurator', @@ -155,7 +156,7 @@ export default { return this.$store.state.lang.language }, isDev() { - return window.environment.FEATURE_DEVELOPER ?? false + return getEnv().FEATURE_DEVELOPER ?? false }, }, watch: { diff --git a/frontend/src/components/print/print-nuxt/PrintPreviewNuxt.vue b/frontend/src/components/print/print-nuxt/PrintPreviewNuxt.vue index 96539377d2..a955781f23 100644 --- a/frontend/src/components/print/print-nuxt/PrintPreviewNuxt.vue +++ b/frontend/src/components/print/print-nuxt/PrintPreviewNuxt.vue @@ -28,7 +28,9 @@