在 emberjs 中放置用于开发/测试的资产的地方
Posted
技术标签:
【中文标题】在 emberjs 中放置用于开发/测试的资产的地方【英文标题】:Place to put assets for dev/test in emberjs 【发布时间】:2018-08-21 23:53:53 【问题描述】:我正在使用 mirage 来模拟一些数据,我想用适当的文件模拟 <img>
。
问题是我必须将图像放在/public/assets
中,并且放置在那里的图像也将在稍后部署。
有没有办法避免这种情况?我在 ember cli 网站上找不到推荐 (https://ember-cli.com/user-guide/#asset-compilation)
我找到了一个可以做到这一点的插件(ember-test-assets),但我想尽可能避免安装额外的插件。
谢谢!
【问题讨论】:
【参考方案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();
;
参考资料:
EmberApp.env()
: https://github.com/ember-cli/ember-cli/blob/d97d96aa016fbe8108c2d2744c9823a0ea086b94/lib/broccoli/ember-app.js#L469
broccoli-funnel
:https://github.com/broccolijs/broccoli-funnel(见exclude
)
【讨论】:
本周的好答案!感谢您帮助问答以上是关于在 emberjs 中放置用于开发/测试的资产的地方的主要内容,如果未能解决你的问题,请参考以下文章
Emberjs 没有为背景图像获取 Cordova 资产文件名更改