【问题标题】:Place to put assets for dev/test in emberjs在 emberjs 中放置用于开发/测试的资产的地方
【发布时间】:2018-08-21 23:53:53
【问题描述】:

我正在使用 mirage 来模拟一些数据,我想用适当的文件模拟 <img>

问题是我必须将图像放在/public/assets 中,并且放置在那里的图像也将在稍后部署。

有没有办法避免这种情况?我在 ember cli 网站上找不到推荐 (https://ember-cli.com/user-guide/#asset-compilation)

我找到了一个可以做到这一点的插件(ember-test-assets),但我想尽可能避免安装额外的插件。

谢谢!

【问题讨论】:

    标签: testing ember.js ember-cli ember-cli-mirage


    【解决方案1】:

    您可以在 Broccoli 的帮助下排除 ember-cli-build.js 中的文件

    const EmberApp = require('ember-cli/lib/broccoli/ember-app');
    const Funnel = require('broccoli-funnel');
    
    module.exports = function(defaults) {
      let app = new EmberApp(defaults, {
        // Add options here
      });
    
      // Filter your test files in 'production'
      if (EmberApp.env() === 'production') {
        return new Funnel(app.toTree(), {
          exclude: ['**/test-*'] // e.g. any file prefixxed with 'test-'
        });
      }
      return app.toTree();
    };
    

    参考资料:

    【讨论】:

    • 本周的好答案!感谢您帮助问答
    猜你喜欢
    • 2018-01-15
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2021-11-07
    • 2014-03-14
    • 2017-09-01
    • 1970-01-01
    • 2015-10-05
    相关资源
    最近更新 更多