Say this is my application-name/config/environment
/* jshint node: true */
module.exports = function(environment) {
var ENV = {
modulePrefix: 'app-name',
environment: environment,
rootURL: '/',
locationType: 'auto',
pageTitle: {
separator: ' - ',
// we want to append the nested title as suffix
prepend: false,
// replace completely replaces the outer title we don't want that
replace: false,
},
EmberENV: {
FEATURES: {
// Here you can enable experimental features on an ember canary build
// e.g. 'with-controller': true
},
EXTEND_PROTOTYPES: {
// Prevent Ember Data from overriding Date.parse.
Date: false
}
},
APP: {
// Here you can pass flags/options to your application instance
// when it is created
},
i18n: {
defaultLocale: 'en',
},
};
if (environment === 'test') {
// Testem prefers this...
ENV.locationType = 'none';
// keep test console output quieter
ENV.APP.LOG_ACTIVE_GENERATION = false;
ENV.APP.LOG_VIEW_LOOKUPS = false;
ENV.APP.rootElement = '#ember-testing';
ENV.APP.API_HOST = 'http://ift.tt/2o1uYLi';
}
else if (environment === 'production') {
}
else {
ENV.APP.API_HOST = 'http://ift.tt/2o1uYLi';
}
return ENV;
};
It's pretty much the default generated one, except there is an
API_HOST
in theAPP
sub property in dev & test mode.
Say in a random module I do this
import ENV from 'application-name/config/environment';
console.log(ENV.APP.API_HOST);
What I expect is the value put in .APP.API_HOST
to logged, except I see undefined... If I log ENV.APP
this is what i see
note the application name has been removed.
However checking the global object works?
console.log(ApplicationName.API_HOST);
Now I do not want to access the global object, because it's kinda hacky. It's 2017 and we have es modules now...
What I've tried
- made sure I used the right environment, we haven't tried prod yet, because we don't have a prod build...
- This specific plugin, only to get the same result
- I did ask this question on the help channel on the Ember slack, but I didn't quite have that much success there
:/
Aucun commentaire:
Enregistrer un commentaire