从Brocfile中的构建中排除文件夹

编程入门 行业动态 更新时间:2024-10-25 06:20:35
本文介绍了从Brocfile中的构建中排除文件夹的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧! 问题描述 有没有办法从Brocfile(或任何其他地方)中的构建中排除文件夹。 用例是包装,我在pod中有一个由子应用程序构成的应用程序。例如。

/ app / modules / components / app / modules / app1 / app / modules / app2 / app / modules / app3

我想将它们全部构建环境被设置为开发,或仅仅是例如。 'app1'当环境是'app1'时。任何建议?

我尝试过不同的西兰花文件删除程序,西兰花漏斗和西兰花合并树的组合无效。

var removeFile = require('broccoli-file-removever'); module.exports = removeFile(app.toTree(),{路径:['app / modules / pod1 /','app / modules / pod2 /'] });

解决方案

啊,所以经过真正的思考,实际上正如我之前的例子中的预期一样。

我显然没有足够的关注。 app.toTree()执行此操作太迟了,因为所有内容已经构建并并行。

请参阅: github/ember-cli/ember-cli/blob/master/ADDON_HOOKS.md for

应该做的窍门的钩子是 Addon.prototype.postprocessTree 。现在我们有两个选择,我们可以通过 ember addon 构建一个独立的插件,或者我们可以通过 ember g创建一个轻量级的内置插件在-回购附加。通常对于这些类型的情况,我更喜欢内置插件,因为它们不需要第二个项目,但是它们是相同的。

  • ember g in-repo-addon删除
  • 我们需要通过安装西兰花炖饭npm install --save broccoli-stew
  • 包含 var stew = require('broccoli-stew');
  • 添加后缀处理Tree到加载项
  • 当postprocessTree是我们关心的类型,使用西兰花炖肉去除我们不再在乎的目录。
  • 生成的拉请求: github/WooDzu/ember-exclude-pod/pull/1

    注意:我注意到模板不是后处理中可用的类型之一,所以我补充说: github/ember-cli/ ember-cli / pull / 4263 (应该是下一个ember-cli版本的一部分)

    注意:我们真的想要一个额外的钩子 Addon.prototype.preprocessTree ,以免我们甚至构建它们之前的文件。我已经开启了一个相关的问题: github/ ember-cli / ember-cli / issues / 4262

    以上步骤的输出

    var stew = require('broccoli-stew'); module.exports = { name:'remove', isDevelopingAddon:function(){ return true; }, postprocessTree:function(type,tree){ if(type ==='js'|| type ==='template'){ return stew.rm(tree,'* / modules / pod {1,2} / ** / *'); } else { return tree; } } };

    Is there a way to exclude a folder from a build in a Brocfile (or any other place). The use case is packaging, where I have an app made of sub-apps within pods. eg.

    /app/modules/components /app/modules/app1 /app/modules/app2 /app/modules/app3

    I'd like to build them all when environment is set to 'development' or only eg. 'app1' when environment is 'app1'. Any suggestions?

    I have tried different combinations of broccoli-file-remover, broccoli-funnel and broccoli-merge-trees to no avail.

    var removeFile = require('broccoli-file-remover'); module.exports = removeFile(app.toTree(), { paths: ['app/modules/pod1/', 'app/modules/pod2/'] });

    解决方案

    Ah, so after actually thinking about this clearly, everything is actually working exactly as expected in my previous example.

    I clearly wasn't paying enough attention. app.toTree() is far too late to perform this operation, as everything has already been built and concated.

    Luckily, ember-cli does enable addons to modify the appropriate trees at various life cycle milestones.

    See: github/ember-cli/ember-cli/blob/master/ADDON_HOOKS.md for more details on which hooks are currently available.

    The hook that should do the trick is Addon.prototype.postprocessTree. Now we have two choices, we can build a standalone addon, via ember addon or we can create a light-weight in-repo addon via ember g in-repo-addon. Typically for these types of situations, I prefer in-repo-addons as they don't require a second project, but otherwise they are the same.

  • ember g in-repo-addon remove
  • we need to install broccoli-stew via npm install --save broccoli-stew
  • include it var stew = require('broccoli-stew');
  • add hook postprocessTree to the add-on
  • when the postprocessTree is for the type we care about, use broccoli-stew to remove the directories we no longer care care.
  • The resulting pull request: github/WooDzu/ember-exclude-pod/pull/1

    Note: I noticed template wasn't one of the types available in postprocess, so I added it: github/ember-cli/ember-cli/pull/4263 (should be part of the next ember-cli release)

    Note: we really do want an additional hook Addon.prototype.preprocessTree, as to ignore the files before we even build them. I have opened a related issue: github/ember-cli/ember-cli/issues/4262

    output of the above steps

    var stew = require('broccoli-stew'); module.exports = { name: 'remove', isDevelopingAddon: function() { return true; }, postprocessTree: function(type, tree){ if (type === 'js' || type === 'template') { return stew.rm(tree, '*/modules/pod{1,2}/**/*'); } else { return tree; } } };

    更多推荐

    从Brocfile中的构建中排除文件夹

    本文发布于:2023-11-16 16:58:56,感谢您对本站的认可!
    本文链接:https://www.elefans.com/category/jswz/34/1606151.html
    版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
    本文标签:文件夹   Brocfile

    发布评论

    评论列表 (有 0 条评论)
    草根站长

    >www.elefans.com

    编程频道|电子爱好者 - 技术资讯及电子产品介绍!