grunt-init模板条件拷贝文件 [英] grunt-init template conditional copy files

查看:108
本文介绍了grunt-init模板条件拷贝文件的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我刚开始使用grunt-init。我有一切工作。
我想知道是否有办法根据以前提示的答案来提示条件复制根文件。

您可以通过 rename.json 文件-excluding-template-filesrel =nofollow> docs



道具应该是要复制/不复制的文件的路径,并且该值可以是带有条件的模板字符串。例如,假设您有两个不同的 main.js 文件,其中一个是空的,另一个是您想要重复使用的代码:

  {
app / js / main-empty.js:{%if(empty){%} app / js / main.js {% }},
app / js / main-skeleton.js:{%if(!empty){%} app / js / main.js {%}%}
}

destpath 检查 props.empty 变量来自 template.js 文件,正确复制并重命名。



以下是链接,显示例如,template.js rename.js


I've just started using grunt-init. I have everything working. And I was wondering if there is a way to do conditional copy root files based on prompts which based on answers to previous prompts.

解决方案

You can make use of the rename.json file via the docs.

The prop should be the path to the file you want to copy/not copy, and the value can be a template string with a conditional. For example, let's say you had two different main.js files, one empty and one with code you tend to re-use:

{
  "app/js/main-empty.js": "{% if (empty) { %}app/js/main.js{% } %}",
  "app/js/main-skeleton.js": "{% if (!empty) { %}app/js/main.js{% } %}"
}

The destpath checks the value of the props.empty variable from your template.js file, copies and renames correctly.

Here is a link to a gist showing the template.js and rename.js for that example.

这篇关于grunt-init模板条件拷贝文件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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