Ecosyste.ms: Awesome

An open API service indexing awesome lists of open source software.

Awesome Lists | Featured Topics | Projects

https://github.com/leon-dunamu/svelte-use-env

use env for svelte/templates
https://github.com/leon-dunamu/svelte-use-env

environment-variables npm svelte svelte-template

Last synced: 26 days ago
JSON representation

use env for svelte/templates

Awesome Lists containing this project

README

        

# svelte withe environment variables

The sveltejs/template starter project doesn’t allow the use of environment variables out-of-the-box.

Env can be used by using this module with svelte.



## how to use


### installation

```bash
npm install @goesvt/svelte-use-env
```


### useage

Just following below code.

in `rollup.config.js` file

```jsx
...

import insertEnv from "@goesvt/svelte-use-env";

const production = !process.env.ROLLUP_WATCH;

...

export default {
...,
plugins : [
...,
insertEnv(), // insert here !!
],
...
}
```


then, you can create & use `.env` file as follows

```bash
APP_KEY=vr9e29399g83gnrvesd
```


```jsx
/* App.js */

console.log(process.env.APP_KEY); // vr9e29399g83gnrvesd
```