This is currently possible:
ember build --environment=production
... and I would like to do something like this instead:
ember build --environment=production --baseurl=foo
but config/environment.js
only gets passed in the value of environment
.
Is it possible to get the value of the other options passed in at the command line too?
This is currently possible:
ember build --environment=production
... and I would like to do something like this instead:
ember build --environment=production --baseurl=foo
but config/environment.js
only gets passed in the value of environment
.
Is it possible to get the value of the other options passed in at the command line too?
Share Improve this question asked Jul 7, 2014 at 5:24 bguizbguiz 28.6k49 gold badges163 silver badges250 bronze badges4 Answers
Reset to default 9You could set environment variables the old fashioned way (export WHATEVER=wee
) from terminal or as part of a build script, then reference them in your Brocfile.js
via node with process.env.WHATEVER
. After that, it would be a matter of having broccoli do whatever it is you needed to do with them. You could pre-process files and replace strings, for example.
... just a suggestion. Not sure if that's what you're looking for or not.
It appears that this is not allowed:
Looking in node_modules/ember-cli/lib/commands/build.js
, we see:
availableOptions: [
{ name: 'environment', type: String, default: 'development' },
{ name: 'output-path', type: path, default: 'dist/' }
],
... and in node_modules/ember-cli/lib/models/command.js
this.availableOptions.forEach(function(option) {
knownOpts[option.name] = option.type;
});
... which together mean that any options that are not defined, for each subcommand of ember
, get discarded.
You can do foo=bar ember build
(however doing ember build foo=bar
doesn't work)
And the argument is available via process.env.foo
.
To extend upon @ben's answer.
The raw command line arguments are available inside ember-cli-build.js
and other files from the
process.argv.[]
So a command like this
ember build staging
you can access via:
process.argv.includes('staging')
see node's documentation for whats available.
https://nodejs.org/docs/latest/api/process.html