karthikaruna
karthikaruna

Reputation: 3236

Regarding custom builds in Ember

How do I extend my custom environment (and build), for example, "staging" from production?

Ultimately I want to do ember build --environment=staging, reap the goodness and optimization provided by "production" build + want to provide some custom config.

Upvotes: 2

Views: 165

Answers (2)

jrjohnson
jrjohnson

Reputation: 2459

This is harder to do than it probably should be and isn't recommended as I hope providing some instructions will make clear. The first step is to modify your config/environment.js file with whatever customization you want. Might look like

if (environment === 'staging') {
 //set something
}

But then you have to deal with other things that production brings to the table automatically. For example fingerprinting of assets is only done in production so you have to modify emebr-cli-build.js to add some instructions to make staging like production.

module.exports = function(defaults) {
  const env = EmberApp.env() || 'development';
  const isProductionLikeBuild = ['production', 'staging'].indexOf(env) > -1;

  const app = new EmberApp(defaults, {
    fingerprint: { enabled: isProductionLikeBuild },
    sourcemaps: { enabled: isProductionLikeBuild },
    minifyCSS: { enabled: isProductionLikeBuild },
    minifyJS: { enabled: isProductionLikeBuild },

    tests: env.EMBER_CLI_TEST_COMMAND || !isProductionLikeBuild,

There are probably more things that production does, but those are the ones I know about.

Another place to look is in config/targets.js where you will find the line const isProduction = process.env.EMBER_ENV === 'production'; which needs to be changed for your new environment as well.

Upvotes: 2

mattbeiswenger
mattbeiswenger

Reputation: 393

I would recommend using ember-cli-deploy. It essentially lets you create deploy "targets" that can have different environmental variables and what not, while giving you the benefit of minified files, fingerprinting, etc. that's included in Ember's production build.

Upvotes: 1

Related Questions