Exclude custom adapter from production build

My Ember application (ember-cli:3.4.4 ember-data:3.4.0) has a custom application Adapter which can redirect requests to a simulation back-end, used only for testing purposes, when a flag named simulation existing in development environment is set to true. In production builds this is completely useless.

Is there a way to exclude the custom Adapter from production builds?

Here’s one way to do it:

// ember-cli-build.js
const EmberApp = require('ember-cli/lib/broccoli/ember-app');
const Funnel = require('broccoli-funnel');

module.exports = function(defaults) {
  let app = new EmberApp(defaults, {
    trees: {
      app: EmberApp.env() === 'production' ? new Funnel('app', { exclude: ['adapters/custom.js'] }) : 'app'
    }
  });
  return app.toTree();
};
1 Like

Thank you very much!