Silence your Ember app in Production

If you've ever wanted to silence your Ember app's console messages (including deprecation warnings) in production, you are not alone.

After a little digging, I found a suitable solution with ember-cli-defeatureify.

ember-cli-defeatureify

defeatureify allows you to create feature flags customized to your application. As a bonus it also provides an enableStripDebug flag that will allow you to strip 'debug' messages from your app.

Using enableStripDebug, and a pretty good list of all console debug methods, I was able to conjure up a configuration that effectively silenced my app in production:

$ ember install ember-cli-defeatureify
// ember-cli-build.js

var app = new EmberApp(defaults, {  
  // ... 
  defeatureify: {
    enableStripDebug: true,
    debugStatements: [
      'Ember.default.warn',
      'Ember.default.assert',
      'Ember.default.deprecate',
      'Ember.default.debug',
      'Ember.default.Logger.assert',
      'Ember.default.Logger.debug',
      'Ember.default.Logger.error',
      'Ember.default.Logger.info',
      'Ember.default.Logger.log',
      'Ember.default.Logger.warn',
      'console.assert',
      'console.clear',
      'console.count',
      'console.debug',
      'console.dir',
      'console.dirxml',
      'console.error',
      'console.group',
      'console.groupCollapsed',
      'console.groupEnd',
      'console.info',
      'console.log',
      'console.profile',
      'console.profileEnd',
      'console.select',
      'console.table',
      'console.time',
      'console.timeEnd',
      'console.trace',
      'console.warn',
    ],
    features: {}
  }
});