2

我正在通过 jenkins 部署 Ember CLI 应用程序并使用 nginx 发布它。这是詹金斯构建脚本:

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

nginx 配置只是sub.domain.com指向jenkins\jobs\lastStable\archive\dist. 效果很好,但是当我转到页面时,它是空白的,并且控制台中的输出如下:

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

我猜这两个错误是相关的,但我不知道是什么原因造成的。我已经尝试过这个似乎是类似问题的答案,但它对我不起作用。在我的开发环境中一切正常,我在Brocfile.js.

4

3 回答 3

3

我正在使用的第三方库之一有同样的问题。

我正在使用这个解决方案:https ://github.com/rwjblue/_____ember-cli-test/commit/1a26911def6f04a4badee94c8a62d8205258867b

我的Brocfile.js区别:

-var app = new EmberApp();
+var app = new EmberApp({
+  vendorFiles: {
+    'handlebars.js': {
+      production: 'bower_components/handlebars/handlebars.js'
+    }
+  }
+});
于 2014-10-10T04:42:25.697 回答
1

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

于 2014-10-09T01:31:49.097 回答
0

我在 ember 包的引导程序中遇到了同样的问题。临时解决方案(来自 GH)是在生产中包含整个 handlebars.js 文件:

var fileMover   = require('broccoli-file-mover');

var vendorTree = fileMover('vendor', {
    files: {
        'handlebars/handlebars.js': 'handlebars/handlbars.runtime.js'
    }
});

var app = new EmberApp({
    vendorFiles: {
        'handlebars.js': {
            production:  'vendor/handlebars/handlebars.min.js'
    }
   }
});
于 2014-10-10T07:47:20.977 回答