Git Product home page Git Product logo

ionic-environment-variables's Introduction

ionic-environment-variables

Demonstration on how to easily setup environment variables in Ionic.

Sets environment variables based on if Ionic >= 3 is running with the --prod flag. Adds just a single line to Ionic's default Webpack configuration.

If you need more than dev and prod (all that Ionic supports), you can use your Node environment (NODE_ENV) instead. For this demo both are used, but in a real app choose one, using both isn't intuitive.

After changing the Webpack config, all the logic is encapsulated in the environment-variables module, so it's easy to copy and paste this solution into any Webpack configured Angular 4 app.

Use 'dev' environment variables

ionic serve

Use 'prod' environment variables

npm run ionic:serve:prod as ionic serve does ignore the --prod option. Or simply set NODE_ENV to 'prod' before running serve, which is what that npm script does.

Do 'prod' builds for a platform

When building for a platform you can use e.g. ionic cordova build ios --prod or ionic cordova emulate ios --prod as a shorthand for using the 'prod' environment variables in your build.

Use 'qa' environment variables

npm run ionic:serve:qa Or simply set NODE_ENV to 'qa' before running serve, which is what that npm script does.

Companion to roblouie's tutorial here, upgraded to Ionic 3 with Angular 4 http://www.roblouie.com/article/296/ionic-2-environment-variables-the-best-way/

ionic-environment-variables's People

Contributors

roblouie avatar bfassbender avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.