Conditionally import assets in ember-cli-build.js

Hi Guys,

Just wanted to drop another quick post about how to conditionally import assets in ember-cli-build.js. I needed to do that in order to make ember-cli-page-object work in development mode.

Apparently there’s already an issue open on github about this situation, but since it’s a solution for the addon and not the user, I’m going to add it here (until a PR lands you have to do this). Since the ember-cli-build.js file is a regular javascript file you can simply drop these lines on it.

// ember-cli-build.js

if (!app.isProduction) {

app.isProduction is a variable defined in ember-cli/lib/broccoli/ember-app, not entirely sure if it’s public API but it gets the job done.

Happy coding!

Leave a Reply

Your email address will not be published. Required fields are marked *