Skip to content

alepop/stencil-env

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

25 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

@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

import { Config } from '@stencil/core';
import { env } from '@alepop/stencil-env';

export const config: Config = {
  plugins: [
      env()
  ]
};

You can additionally, pass options to the env plugin.

Add .env file in the root of your project

.env

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