Search code examples
ember.jsjenkinsember-clibroccolijs

Ember CLI fails in production


I am deploying an Ember CLI app through jenkins and publishing it using nginx. Here is by jenkins build script:

npm install
bower install
node_modules/ember-cli/bin/ember build --environment=production

The nginx configuration simply directs sub.domain.com to jenkins\jobs\lastStable\archive\dist. That works fine, but when I go the page, it is blank and the following output in the console:

TypeError: Ember.Handlebars.compile is not a function   vendor-92ab6507ac60a5bf7c6819aa8fc418d6.js:18
ReferenceError: Swag is not defined   spa-client-9b01c6124f5b2a4cd2e95b62be7f5ba5.js:1

I am guessing that the two errors are related, but I can't figure out what is causing them. I have tried this answer to what appears to be a similar question, but it doesn't work for me. Everything works fine in my dev environment, and I can't see anything suspicious in the Brocfile.js.


Solution

  • Production uses handlebars-runtime which does not include Ember.Handlebars.compile. The reason is that it's smaller to use that in production and it's more effective to precompile which ember-cli does for you automatically.

    Lots of discussion on the PR found here