gulp可以获取文件所在的路径吗?

我现在的构建:

 gulp.watch("web_swan_mt/stc/tpl/**/*.html",function(e){
      console.log("tpl change");
      console.log('-File- ' + e.path + ' -was- ' + e.type + ', -running tasks...');
 });
 
获取的路径是:F:\\business_bd\web_swan_mt\stc\tpl\monthlyBill\countlist.html

我想只获取到F:\\business_bd\web_swan_mt\stc\tpl\monthlyBill


 这个路径,也就是这个html文件所在的目录路径?请问有什么gulp插件或者api可以获取到吗?
阅读 5k
1 个回答

"web_swan_mt/stc/tpl/**/" 这样不行吗?

Gulp内部使用了node-glob模块来实现其文件匹配功能。glob 请参考 node-glob语法。

如果你是想监听tpl下的所有文件件下的文件可以怎么写啊:web_swan_mt/stc/tpl/**/**
或者就分类型分别监听:web_swan_mt/stc/tpl/**/*.js 、web_swan_mt/stc/tpl/**/*.html

撰写回答
你尚未登录,登录后可以
  • 和开发者交流问题的细节
  • 关注并接收问题和回答的更新提醒
  • 参与内容的编辑和改进,让解决方法与时俱进