Route only in DEV mode?



Somebody know how to define a route (in the router) only in DEV mode. I would like files (controller, route, template) associated with this route are not compiled in the PROD build too.

Thanks for your help


I tried to use runInDebug to add a “debug” route in the router.js but unfortunately, the code anout the add in the router, the route and its template is still present in the app compiled version (mode prod) :confused:.


I think i can use ember-cli-funnel to remove route and template code :grinning:


How are you filtering out the route using that package?


Yes I would be curious to know how you’re using that package to filter things as well…


I’m filtering ‘debug’ route and template like this :

// ember-cli-build.js
'use strict';

const EmberApp = require('ember-cli/lib/broccoli/ember-app');

module.exports = function(defaults) {
  let exclude = [];

  switch (EmberApp.env()) {
    case 'production':

  let app = new EmberApp(defaults, {
    funnel: {
      enabled: true,

  return app.toTree();
// app/router.js
import EmberRouter from '@ember/routing/router';
import config from './config/environment';

const Router = EmberRouter.extend({
  location: config.locationType,
  rootURL: config.rootURL
}); {
  if (config.environment === "development") {


export default Router;

But if i use debug route link in my app, I need to check environment value too :confused: :

// app/templates/application.hbs

{{#if isDev}}
  <li>{{#link-to "debug"}}Debug{{/link-to}}</li>
<li>{{#link-to "another"}}Another{{/link-to}}</li>


So I always have some traces (if statments) in my production code (in the router.js and application.hbs here) :frowning:


At work we are using freestyle and the easiest way we found to have it as a dev only route and filter it from the build is to make an in-repo add-on that gets blacklisted in prod builds.

Thanks to Simplabs and specifically Tobias Bieniek for the idea and most of the implementation below. Re: this blog post

The add-on has an instance-initializer lib/freestyle/instance-initializers/freestyle.js that adds the route and controller.

/* global window */
import Router from '../router';
import Route from '@ember/routing/route';
import { inject as service } from '@ember/service';

const FreestyleRoute = Route.extend({
  router: service(),

  renderTemplate() {
    this.render('freestyle', {
      controller: this.controllerFor('freestyle'),

export function initialize(appInstance) {
  let router = appInstance.lookup('service:router');
  let initialURL = router.currentURL || (window && window.location ? window.location.href : '');
  if (initialURL.match('/freestyle')) {
    appInstance.register('route:application', FreestyleRoute); {

export default {
  name: 'freestyle',
  initialize: initialize,

then ember-cli-build.js filters out the add-on

const env = EmberApp.env() || 'development';
const pluginsToBlacklist = env === 'production' ? ['ember-freestyle', 'freestyle'] : [];

Works really well and allows nice separation.