support global env const in js and hbs for ember app.
- support js and hbs files
- minify code in production mode
- Ember.js v3.2 or above
- Ember CLI v2.13 or above
- Node.js v10 or above
ember install ember-cli-global-env
By default, automatic import all APP-* variables in process.env, so you can use it directly;
otherwise, your can define extra const in config/global-env.js.
// config/global-env.js
module.exports = function (environment) {
const flags = {
CFX: process.env['APP_BRAND'] === 'cfx',
Token: 'xxxxxx'
};
return flags;
};Additional options can be specified using the global-env config property in ember-cli-build.js:
let app = new EmberApp({
'global-env': {...}
});Available Options:
helperName: default is env, a helper for access global env in templateimportPath: default is @global/env, so you can import global env from this path
source:
output (in building before opcode) :
source:
import { CFX, Token } from '@global/env';
export default class IndexRoute extends Route {
init() {
console.log(Token);
if (!CFX) {
console.log('cfx logic');
}
}
}output (in production mode)
export default class IndexRoute extends Route {
init() {
console.log('xxxxxx');
}
}See the Contributing guide for details.
This project is licensed under the MIT License.