【问题标题】:Peeking behind ember-cli (EmberApp): vendor.js and app.js窥探 ember-cli (EmberApp):vendor.js 和 app.js
【发布时间】:2015-06-22 16:22:00
【问题描述】:

有了优秀的broccoli-stew我可以看看导出的应用树:

/* global require, module */

var EmberApp = require('ember-cli/lib/broccoli/ember-app');

var log   = require('broccoli-stew').log;
var debug = require('broccoli-stew').debug;

var app = new EmberApp();

// Use `app.import` to add additional libraries to the generated
// output files.
//
// If you need to use different assets in different
// environments, specify an object as the first parameter. That
// object's keys should be the environment name and the values
// should be the asset to use in that environment.
//
// If the library that you are including contains AMD or ES6
// modules that you would like to import into your application
// please specify an object with the list of modules as keys
// along with the exports of each module as its value.

app.import('bower_components/ember-i18n/lib/i18n.js');
app.import('bower_components/raphael/raphael.js');

var finalTree = log(app.toTree());

module.exports = finalTree;

有了这个,我的应用程序得到了一个非常干净的树状输出:​​

[ 'assets/app.js',
  'assets/app.map',
  'assets/app.scss',
  ...
  'assets/vendor.css',
  'assets/vendor.js',
  'assets/vendor.map',
  'crossdomain.xml',
  'index.html',
  'robots.txt',
  'testem.js',
  'tests/index.html' ]

我看到在那棵树中,除其他文件外,我们还有一个 vendor.js 和一个 app.js 模块(如预期的那样),但我不知道每个模块都放入了哪些包。

我感觉我的前端缺少一个(在这种情况下,raphael.js),所以我想验证ember-cli(通过EmberApp)确实完成了我的要求(即,包括raphael.js,可能在vendor.js)

直接看app.jsvendor.js 是不可行的(太大/不知道要找什么)。我想要以与broccoli-stew 提供的相同(相似)格式将EmberApp 包含到vendor.js / app.js 中的文件以简单的树状显示。

这可能吗?怎么样?

【问题讨论】:

    标签: ember.js ember-cli broccolijs


    【解决方案1】:

    引用http://www.ember-cli.com/asset-compilation/#configuring-output-paths

    Assets                                          Output File
    JavaScript files you import with app.import()   /assets/vendor.js
    

    所以虽然这不是一个很好的树视图,但你应该没问题 :-)

    【讨论】:

    • 这是我告诉 EmberApp 做的,而不是 EmberApp 的。希望是一样的,但就我而言,这正是我不确定的情况。我想要一种独立的方式来列出vendor.jsapp.js 的内容。
    • 如果你真的想看看 Ember 在做什么,看看函数的源代码:github.com/ember-cli/ember-cli/blob/master/lib/broccoli/…。开源
    • 同理,我不需要broccoli-stew,也不需要调试器,或者……看代码!而且,这些工具仍然非常有用。无论如何,我认为一旦生成 vendor.jsapp.js 的内容,就无法列出它们。
    猜你喜欢
    • 1970-01-01
    • 2022-06-14
    • 2015-06-14
    • 1970-01-01
    • 2017-02-27
    • 2021-01-09
    • 1970-01-01
    • 1970-01-01
    • 2020-02-24
    相关资源
    最近更新 更多