JEricaM
JEricaM

Reputation: 824

Enviroment variabiles in APK from Ionic Stencil PWA starter

My project it's a Stencil+Ionic PWA starter and I'm using file .env to use my enviroment variables. On browser it's okay, but If I use Appflow and I create an APK, I have the error "process is note defined"

How can I use the enviroment variabiles to work properly on native builds? I'm not using Angular and I've found only Angular solutions. I don't have Growth plan so I can't use enviroment in Appflow.

Upvotes: 0

Views: 88

Answers (1)

Simon Hänisch
Simon Hänisch

Reputation: 4968

Since version 2.3.0, Stencil has an env option in stencil.config.ts. It was added in this commit, which is the only documentation that's currently available for it.

Basically you do something like

// stencil.config.ts

export const config: Config = {
  // ...
  env: {
    FOO: 'bar'
  }
}

and then in your modules you can import Env from Stencil:

import { Component, Env } from '@stencil/core';

@Component({ tag: 'my-component' })
export class MyComponent {
  render() {
    return <p>{Env.foo}</p>
  }
}

Upvotes: 1

Related Questions