javascript - Grunt Globbing 模式

标签 javascript node.js gruntjs

实现以下目标需要什么模式。

  1. 匹配.tmp目录下的所有html文件>
  2. 匹配 .tmp/views 中的所有 html 文件及其所有子目录(递归到任意深度)

这是在 Grunt 文件中注册 livereload 任务。

我尝试了以下几种配置。它匹配.tmp中的所有文件,但不匹配.tmp/views

中的所有文件

也试过了,

 '.tmp/{,views/**/}*.html'

但结果相同。

 livereload: {
                    options: {
                        livereload: LIVERELOAD_PORT
                    },
                    files: [
                        '.tmp/{,views/**}*.html'
                    ]
                }

最佳答案

你应该能够通过传递文件数组中的两个元素来获得你需要的匹配:

files: [
    '.tmp/*.html',
    '.tmp/views/**/*.html',
]

这将匹配 .tmp/ 正下方的任何 .html 文件,以及 .tmp 中的任何 .html 文件/views/,无论是直接在该目录下还是更深(/**/ 部分)。

关于javascript - Grunt Globbing 模式,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/18068174/

相关文章:

javascript - 在 OpenCart 中自动隐藏警报消息

mysql - Node.js、Express、MySQL - 更新架构

html - 如何在不使用任何框架的情况下访问以表单提交的数据,该数据用nodejs保存为另一个文件

javascript - 配置 grunt.js 将 Bower 文件夹中的文件一一缩小

javascript - 函数根据 setinterval 循环但具有不同的参数

javascript - 减少对 JavaScript 库的需求

javascript - 按链接时将 href 加载到 div 中?

python - 在 Azure IoT 中心收到消息时触发函数

javascript - 找不到 "autoprefixer"任务的插件

node.js - 如何更新 node.js 并在 Travis CI 的 python 项目中安装 grunt/bower?