https://github.com/alepop/stencil-env
🎛️ `.env` plugin for stencil
https://github.com/alepop/stencil-env
dotenv plugin stencil stenciljs
Last synced: 3 months ago
JSON representation
🎛️ `.env` plugin for stencil
- Host: GitHub
- URL: https://github.com/alepop/stencil-env
- Owner: alepop
- License: mit
- Created: 2018-12-20T13:44:54.000Z (over 7 years ago)
- Default Branch: master
- Last Pushed: 2021-01-20T06:23:33.000Z (over 5 years ago)
- Last Synced: 2025-10-23T21:17:45.409Z (7 months ago)
- Topics: dotenv, plugin, stencil, stenciljs
- Language: TypeScript
- Homepage: https://www.npmjs.com/package/@alepop/stencil-env
- Size: 21.5 KB
- Stars: 14
- Watchers: 1
- Forks: 4
- Open Issues: 4
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# @alepop/stencil-env
This package is used to use env variables from `.env` file in your stencil project files.
First, npm install within the project:
```
npm install @alepop/stencil-env --save-dev
```
Next, within the project's `stencil.config.js` file, import the plugin and add
it to the `plugins` config.
#### stencil.config.ts
```ts
import { Config } from '@stencil/core';
import { env } from '@alepop/stencil-env';
export const config: Config = {
plugins: [
env()
]
};
```
You can additionally, pass [options](https://github.com/motdotla/dotenv#options) to the `env` plugin.
Add `.env` file in the root of your project
### .env
```bash
TEST=test string
```
After compilation, `process.env.TEST` will be replaced by it variable from `.env` file.
### Gotchas
You should to take in mind that `process.env` will not exist as usable object in your project when you use this plugin. It's only replace exact `.env` variable with it's value on a build phase.
## Related
* [Stencil](https://stenciljs.com/)
* [Stencil Worldwide Slack](https://stencil-worldwide.slack.com)
* [dotenv](https://github.com/motdotla/dotenv)