在emberjs中放置用于开发/测试的资产的位置 [英] Place to put assets for dev/test in 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();
};
参考文献:
-
EmberApp.env()
: https://github.com/ember-cli/ember-cli/blob/d97d96aa016fbe8108c2d2744c9823a0ea086b94/lib/broccoli/ember-app.js#L469 -
西兰花漏斗
: https://github.com/broccolijs/broccoli-funnel (请参阅exclude
)
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:
EmberApp.env()
: https://github.com/ember-cli/ember-cli/blob/d97d96aa016fbe8108c2d2744c9823a0ea086b94/lib/broccoli/ember-app.js#L469broccoli-funnel
: https://github.com/broccolijs/broccoli-funnel (seeexclude
)
这篇关于在emberjs中放置用于开发/测试的资产的位置的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!