Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to set flags in ember-cli, other than environment?

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?

like image 353
bguiz Avatar asked Jul 07 '14 05:07

bguiz


People also ask

What is Ember CLI?

Ember CLI, Ember's command line interface, provides a standard project structure, a set of development tools, and an addon system. This allows Ember developers to focus on building apps rather than building the support structures that make them run.

How do I open Ember command line?

Open http://localhost:4200 in your browser of choice. You should see an Ember welcome page and not much else.

How do I use Ember components?

If you need to customize the behavior of the component you'll need to define a subclass of Component . For example, you would need a custom subclass if you wanted to change a component's element, respond to actions from the component's template, or manually make changes to the component's element using JavaScript.

How does Ember serve work?

What it does. ember serve takes all of the app's files and turns them into something that can be rendered in the browser. By default, we can view the app by visiting http://localhost:4200 . It's a good idea to keep the server running as we work so that we know as soon as possible that we've broken something.


2 Answers

You 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.

like image 191
Ben Lesh Avatar answered Sep 28 '22 02:09

Ben Lesh


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.

like image 35
bguiz Avatar answered Sep 28 '22 03:09

bguiz