【问题标题】:where is the real time copy of the index.html that ember-cli serves?ember-cli 提供的 index.html 的实时副本在哪里?
【发布时间】:2016-02-03 08:22:03
【问题描述】:

如何从 ember-cli 的 tmp 文件夹获取最新的 index.html 文件?

我正在对生成的 index.html 的最终副本进行一些后期处理,但我无法找到文档或参考资料,说明如何在获取 GET 时提供 html 之前在节点端拾取此路径请求正在被兑现。

基本上,我有一个用例来操作 index.html,添加一些标签(实时)。现在我使用dist/index.html,但这似乎只是一个临时副本。

【问题讨论】:

  • 可能会在ember-cli-build.js 中更改构建过程。那里的树应该包含index.html 文件,该文件将被传输到 tmp 和以后的 dist 文件夹。

标签: node.js express ember.js ember-cli serve


【解决方案1】:

查看ember-index addon,它允许您将内容注入index.html。从他们的multiple injection example 你会想要这样的东西:

ember-cli-build.js

/* global require, module */
var EmberApp = require('ember-cli/lib/broccoli/ember-app');

module.exports = function(defaults) {
  var app = new EmberApp(defaults, {
    'ember-index': {
      content: [{
        key: 'content',
        file: 'example.txt',
        includeInOutput: true,
        includeInIndexHtml: true
      }]
    }
  });

  return app.toTree();
};

app/index.html

<!DOCTYPE html>
<html>
  <head>
     {{content-for 'ember-index-content'}}
     ...
  </head>
  <body>
     ...
  </body>
</html>

这会将example.txt的内容注入index.html的头部。

【讨论】:

    猜你喜欢
    • 2015-12-14
    • 2014-08-12
    • 1970-01-01
    • 2014-01-06
    • 2015-01-25
    • 1970-01-01
    • 1970-01-01
    • 2021-03-29
    • 2013-07-01
    相关资源
    最近更新 更多