在emberjs中放置用于开发/测试的资产的位置 [英] Place to put assets for dev/test in emberjs

查看:63
本文介绍了在emberjs中放置用于开发/测试的资产的位置的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在使用海市rage楼来模拟某些数据,我想使用适当的文件来模拟< img>



问题是我将不得不将映像放置在 / public / assets 中,并且放置在该映像上也将在以后部署。 / p>

有办法避免这种情况吗?我在ember cli网站( https:// ember- cli.com/user-guide/#asset-compilation



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



谢谢!

解决方案

在西兰花的帮助下,您可以排除 ember-cli-build.js 中的文件

  const EmberApp = require('ember-cli / lib /西兰花/ ember-app'); 
const Funnel = require(西兰花漏斗);

module.exports = function(defaults){
let app = new EmberApp(defaults,{
//在此处添加选项
});

//在生产中过滤测试文件
if(EmberApp.env()==='production'){
return new Funnel(app.toTree() ,{
排除:['** / test- *'] //例如,任何以'test-'
前缀的文件));
}
return app.toTree();
};

参考文献:




I'm using mirage to mock some data and I'd like to mock an <img> with the appropriate file.

The problem is that I will have to place the image in /public/assets and the images placed there will be deployed later on as well.

Is there a way to avoid this? I couldn't find a recommendation in the ember cli website (https://ember-cli.com/user-guide/#asset-compilation)

I found one addon that could do this (ember-test-assets), but I'd like to avoid installing extra addons as much as possible.

Thanks!

解决方案

You can exclude files in ember-cli-build.js with some help of Broccoli

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();
};

References:

这篇关于在emberjs中放置用于开发/测试的资产的位置的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆