PWA toolkit environment variables


#1

In the pwa toolkit, is there something similar to the angular environment variables? I would like to use a different url for a server in development and in production

Anyone achieved that or could point me to an example?


#2

Not sure it works if I would use SSR but I did the following.

In stencil.config.ts I provided a different globalScript according prod or dev

let globalScript: string = 'src/global/app.ts';

const dev: boolean = process.argv && process.argv.indexOf('--dev') > -1;
if (dev) {
    globalScript = 'src/global/app-dev.ts';
}

export const config: Config = {
    ...
    globalScript: globalScript,
    ...
};

then, for the app itself, I had a look at the Ionic core code and I basically did the same :wink: See setupConfig as start point https://github.com/ionic-team/ionic/blob/838f40de37f68b829ffd4e770baf10ff87989cce/core/src/utils/config.ts