3

我正在使用 ember-cli 并且在选择生产环境时遇到问题。具体来说,当我运行时一切正常,运行时ember serve --environment=development我得到一个空白页ember serve --environment=production。在控制台中,我看到:

  • 未捕获的类型错误:未定义不是函数
  • 未捕获的错误:找不到模块 simple-auth/authenticators/base

所有其他事情都是平等的,并且所有依赖项都是最新的。我是个菜鸟,所以我什至不知道从哪里开始调试:是灰烬吗?余烬cli?西兰花?任何帮助,将不胜感激。

4

2 回答 2

5

我遇到了完全相同的问题,James_1x0 是正确的,这是一个花椰菜问题。调试后,“未定义”错误出现在“Ember.handlebars.compile”上,导致其他研究。看来,在生产环境中,“handlebars.js”在 ember-cli 构建过程中被“handlebars.runtime.js”替换,这对于目前的 broccoli 来说似乎是个问题。

其他开发人员也有同样的问题,但其他库也有: https ://github.com/stefanpenner/ember-cli/pull/675#issuecomment-47431195

这里的解决方案是添加:

    var index = app.legacyFilesToAppend.indexOf('bower_components/handlebars/handlebars.runtime.js');
if(index) {
    app.legacyFilesToAppend[index] = 'bower_components/handlebars/handlebars.js';
}

进入您的 Brocfile.js 以将“handlebars.runtime.js”替换为“handlebars.js”。这也为我解决了这个问题。它确实有一个缺点,即部署了整个车把文件,但目前它是一种解决方法,直到问题得到解决。

于 2014-09-18T15:28:10.080 回答
0

Solution is mentioned on Ember CLI website:

This is somewhat non-standard and discouraged, but suppose that due to a requirement in your application that you need to use the full version of Handlebars even in the production environment.

Basically, you can pass vendorFiles option to your EmberApp instance which will force CLI to include full version of Handlebars.

Example of explicitly requiring handlebars.js , in Brocfile.js:

var app = new EmberApp({
  vendorFiles: {
    'handlebars.js': {
      production: 'bower_components/handlebars/handlebars.js'
    }
  }
});

This is recommended way of solving this issue(discussion on GitHub).

于 2015-01-27T23:01:31.810 回答