Skip to content

Commit

Permalink
Introduce import-meta-env for frontend
Browse files Browse the repository at this point in the history
  • Loading branch information
lwih committed Mar 11, 2024
1 parent 3d10a1b commit 21f111c
Show file tree
Hide file tree
Showing 13 changed files with 639 additions and 61 deletions.
10 changes: 10 additions & 0 deletions frontend/.env.d.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
// https://vitejs.dev/guide/env-and-mode#intellisense-for-typescript
/// <reference types="vite/client" />

interface ImportMetaEnv {
readonly FRONTEND_SENTRY_DSN: string
}

interface ImportMeta {
readonly env: ImportMetaEnv
}
5 changes: 5 additions & 0 deletions frontend/.env.example
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@

################################################################################
# Sentry

FRONTEND_SENTRY_DSN=https://[email protected]/121
4 changes: 4 additions & 0 deletions frontend/.env.local.defaults
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
################################################################################
# Sentry

FRONTEND_SENTRY_DSN=https://[email protected]/121
21 changes: 13 additions & 8 deletions frontend/.gitignore
Original file line number Diff line number Diff line change
@@ -1,11 +1,24 @@
# See https://help.github.com/articles/ignoring-files/ for more about ignoring files.

# env
.env
.env.local
.env.development
.env.development.local
.env.staging
.env.staging.local
.env.production
.env.production.local
.env.test
.env.test.local

# dependencies
/node_modules
/.pnp
.pnp.js
npm-debug.log*
yarn-debug.log*
yarn-error.log*

# testing
/coverage
Expand All @@ -16,11 +29,3 @@

# misc
.DS_Store
.env.local
.env.development.local
.env.test.local
.env.production.local

npm-debug.log*
yarn-debug.log*
yarn-error.log*
9 changes: 9 additions & 0 deletions frontend/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,16 @@
<link rel="manifest" href="./manifest.json"/>
</head>
<body>
<!-- React root -->
<div id="root"></div>

<!-- This script will be used by the `import-meta-env` library to inject -->
<!-- runtime environment variables when running in production -->
<!-- see: https://import-meta-env.org/guide/getting-started/introduction.html -->
<script>
globalThis.import_meta_env = JSON.parse('"import_meta_env_placeholder"')
</script>

<script type="module" src="/src/index.tsx"></script>
</body>
</html>
Loading

0 comments on commit 21f111c

Please sign in to comment.