Skip to content

Commit 501a58a

Browse files
committed
fix: 💫 update environment variable handling
1 parent 213bdd1 commit 501a58a

File tree

6 files changed

+8
-27
lines changed

6 files changed

+8
-27
lines changed

‎.env.EXAMPLE

+1-1
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
VITE_MAPBOX_ACCESS_TOKEN="your.mapbox.access.token"
1+
PUBLIC_MAPBOX_ACCESS_TOKEN="your.mapbox.access.token"

‎README.md

+1-13
Original file line numberDiff line numberDiff line change
@@ -206,19 +206,7 @@ Add a map to your SvelteKit site using <a aria-label="Learn more about Map box"
206206
">LeafletJS</a>. Requires a Mapbox access token, just add it your to the `.env` file in your project:
207207

208208
```plaintext
209-
VITE_MAPBOX_ACCESS_TOKEN=your.token
210-
```
211-
212-
If you don't yet have environment variables configured in your project, add the `dotenv` package:
213-
214-
```shell
215-
pnpm install -D dotenv
216-
```
217-
218-
And the add it in your `svelte.config.js` file:
219-
220-
```javascript
221-
import 'dotenv/config';
209+
PUBLIC_MAPBOX_ACCESS_TOKEN=your.token
222210
```
223211

224212
Add the component to a `.svelte` file in your project:

‎package.json

-1
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,6 @@
3535
"@typescript-eslint/eslint-plugin": "^5.38.0",
3636
"@typescript-eslint/parser": "^5.38.0",
3737
"@vitejs/plugin-basic-ssl": "^0.1.2",
38-
"dotenv": "^16.0.2",
3938
"eslint": "^8.23.1",
4039
"eslint-config-prettier": "^8.5.0",
4140
"eslint-plugin-svelte3": "^4.0.0",

‎pnpm-lock.yaml

+3-10
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

‎src/lib/config/website.ts

+3-1
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
1+
import { PUBLIC_MAPBOX_ACCESS_TOKEN } from '$env/static/public';
2+
13
const website = {
2-
mapboxAccessToken: import.meta.env.VITE_MAPBOX_ACCESS_TOKEN as string,
4+
mapboxAccessToken: PUBLIC_MAPBOX_ACCESS_TOKEN,
35
};
46

57
export { website as default };

‎svelte.config.js

-1
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
11
import adapter from '@sveltejs/adapter-static';
2-
import 'dotenv/config';
32
import preprocess from 'svelte-preprocess';
43

54
/** @type {import('@sveltejs/kit').Config} */

0 commit comments

Comments
 (0)