All Projects → gshigeto → Ionic Environment Variables

gshigeto / Ionic Environment Variables

Licence: mit
Easy to use environment variables for Ionic3!

Projects that are alternatives of or similar to Ionic Environment Variables

ionic3-image-handling
In this ionic tutorial you will learn how to access the image gallery and take pictures from an ionic app. Also we will show you how to add a image cropper. This ionic tutorial includes a working ionic app example you can reuse for your needs.
Stars: ✭ 35 (-87.41%)
Mutual labels:  ionic, angular4, ionic-framework, ionic3
Wooionic3
An eCommerce App for WooCommerce stores using Ionic 3.
Stars: ✭ 208 (-25.18%)
Mutual labels:  ionic, ionic-framework, ionic3, angular4
ionic-app-with-aws-cognito
Angular 4, Ionic 3, and AWS (Amazon) Cognito User Pools. Authentication out of the box.
Stars: ✭ 62 (-77.7%)
Mutual labels:  ionic, angular4, ionic-framework, ionic3
ionic-modal-custom-transitions
Add Custom Transitions to Ionic Modals.
Stars: ✭ 22 (-92.09%)
Mutual labels:  ionic, angular4, ionic-framework, ionic3
fireblogger
Ionic 2 social media microblogging platform built with firebase 3 as backend
Stars: ✭ 54 (-80.58%)
Mutual labels:  ionic, ionic-framework, ionic3
ionic-hockeyapp
Need HockeyApp in your Ionic application, add this package!
Stars: ✭ 19 (-93.17%)
Mutual labels:  ionic, ionic-framework, ionic3
todo-list
TodoList using Ionic2/3 & Firebase: * PWA * SSO Google plus. * Share list via QRcode. * Upload image from Camera or Storage. * Speech Recognition.
Stars: ✭ 18 (-93.53%)
Mutual labels:  ionic, ionic-framework, ionic3
angular-progress-bar
This component allow you to easy incorporate progress-bar to angular/ionic project, providing binding and color options
Stars: ✭ 26 (-90.65%)
Mutual labels:  ionic, angular4, ionic3
ionic3-firebase-ngrx
Sample Ionic 3 application using ngrx with firebase (auth, crud and camera plugin)
Stars: ✭ 48 (-82.73%)
Mutual labels:  ionic, angular4, ionic3
ionic3-start-theme
Ionic 3 Start Theme with 10 Pages, mock data, providers samples, Storage, Http and more...
Stars: ✭ 130 (-53.24%)
Mutual labels:  ionic, ionic-framework, ionic3
ionic-surveyjs
Sample project that shows how to integrate SurveyJS in Ionic APP.
Stars: ✭ 28 (-89.93%)
Mutual labels:  ionic, ionic-framework, ionic3
ionic3-angular4-sample-app
Sample app of Ionic 3 and Angular 4
Stars: ✭ 35 (-87.41%)
Mutual labels:  ionic, angular4, ionic3
ionic-login-component
Free sample of Premium Ionic Login Component
Stars: ✭ 17 (-93.88%)
Mutual labels:  ionic, ionic-framework, ionic3
ionic-native-sms-retriever-plugin-master
Cross-platform plugin for Cordova / PhoneGap to Retrieve SMS. Available for Android.
Stars: ✭ 16 (-94.24%)
Mutual labels:  ionic, ionic-framework, ionic3
ionic-socialsharing-with-deeplinking-example
Ionic Social Sharing and Deep Linking example app. Complete Ionic Tutorial with free example app! Built for Ionic 3.
Stars: ✭ 16 (-94.24%)
Mutual labels:  ionic, ionic-framework, ionic3
ionic-3-video-calling-using-webrtc
This is demo code of how to implement video calling in ionic 3 using webrtc
Stars: ✭ 58 (-79.14%)
Mutual labels:  ionic, ionic-framework, ionic3
ionic-workflow-guide
Create a full and powerful worflow with Ionic (Unit Testing, Environment variables, Automatic documentation, Production App Server, Automatic deployment)
Stars: ✭ 46 (-83.45%)
Mutual labels:  environment-variables, ionic-framework, ionic3
ionic-uuchat
基于ionic3,angular4的实时聊天app,兼容web端。该项目只是前端部分,所有数据需要请求后端服务器,需要配套express-uuchat-api使用。
Stars: ✭ 14 (-94.96%)
Mutual labels:  ionic, angular4, ionic3
Dianoia-app
Mobile (Ionic 3 - Angular 4) app about non-pharmaceutical activities and information for people with dementia.
Stars: ✭ 13 (-95.32%)
Mutual labels:  ionic, angular4, ionic3
ionicfirebaseauth
Exemplo de alguns tipos de autenticação com Ionic 2 e Firebase
Stars: ✭ 18 (-93.53%)
Mutual labels:  ionic, ionic-framework, ionic3

Ionic Environment Variables

With this configuration, you can import environment variables anywhere, even in your app.module.ts. Also supports any number of custom environments (prod, staging, dev, etc.) This project uses the @ionic/app-script package. I recommend updating/installing this package before starting.

Add the following to your package.json:

"config": {
  "ionic_webpack": "./config/webpack.config.js"
}

Add the following to your tsconfig.json in compilerOptions:

"baseUrl": "./src",
"paths": {
  "@app/env": [
    "environments/environment"
  ]
}

Create a file in your base directory config/webpack.config.js and paste the following:

var chalk = require("chalk");
var fs = require('fs');
var path = require('path');
var useDefaultConfig = require('@ionic/app-scripts/config/webpack.config.js');

var env = process.env.IONIC_ENV;

useDefaultConfig.prod.resolve.alias = {
  "@app/env": path.resolve(environmentPath('prod'))
};

useDefaultConfig.dev.resolve.alias = {
  "@app/env": path.resolve(environmentPath('dev'))
};

if (env !== 'prod' && env !== 'dev') {
  // Default to dev config
  useDefaultConfig[env] = useDefaultConfig.dev;
  useDefaultConfig[env].resolve.alias = {
    "@app/env": path.resolve(environmentPath(env))
  };
}

function environmentPath(env) {
  var filePath = './src/environments/environment' + (env === 'prod' ? '' : '.' + env) + '.ts';
  if (!fs.existsSync(filePath)) {
    console.log(chalk.red('\n' + filePath + ' does not exist!'));
  } else {
    return filePath;
  }
}

module.exports = function () {
  return useDefaultConfig;
};

Create a default file src/environments/environment.ts which will be used for your PRODUCTION environment:

export const ENV = {
  mode: 'Production'
}

Create a default file src/environments/environment.dev.ts which will be used for your development environment:

export const ENV = {
  mode: 'Development'
}

You can then import your environment variables anywhere!

import { ENV } from '@app/env'

NOTE Remember to ignore your files in your .gitignore

# Envrionment Variables
**/environment.*
!**/environment.model.ts

To test production builds: ionic build --prod then open the www/index.html file in your browser.

If more than prod and dev environments are wanted

  1. Change your webpack.config.js IONIC_ENV variable to be something else. For example:
var env = process.env.MY_ENV;
  1. Add to your package.json another run script and name it whatever you would like
"serve:testing": "MY_ENV=testing ionic-app-scripts serve"
  1. Create your testing file src/environments/environment.testing.ts. This should be whatever you set your MY_ENV to.
  2. Finally, run the script by using the name you used for your script in package.json
$ npm run serve:testing

NOTE: When running with a custom variable, production builds still need --prod flag

Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].