ember-cli-cordova icon indicating copy to clipboard operation
ember-cli-cordova copied to clipboard

Configuration based way to know if you are building with Cordova

Open jdurand opened this issue 8 years ago • 0 comments

Ember CLI Electron sets an environment variable so you can have your app behave differently depending on the type of build :

// environment.js
module.exports = function(environment) {
  var ENV = {/*...*/};
  if (process.env.EMBER_CLI_ELECTRON) {
    ENV['locationType'] = 'hash';
    // ...
  }
  return ENV;
};

I know the EMBER_CLI_CORDOVA env var is used when you need to build without Cordova. I'd like to be able to configure my app to opt-in instead of opt-out :

// environment.js
module.exports = function(environment) {
  var ENV = {
    cordova: {
      rebuildOnChange: false,
      emulate: false,
      enabledByDefault: false // or something...
    },
  };
  if (process.env.EMBER_CLI_CORDOVA) {
    ENV['locationType'] = 'hash';
    // ...
  }
  return ENV;
};

This could also improve how https://github.com/poetic/ember-cli-cordova/pull/87 is implemented.

Is this something that can already be done another way?

jdurand avatar Apr 29 '16 16:04 jdurand