requirejs r.js 合并压缩脚本,fileExclusionRegExp参数配置无效?


各路大神,跪求解答个问题。
如下图,是我在grunt里的grunt-contrib-requirejs的配置,但其实跟grunt没什么鸟关系啦,最后这个options传给r.js在node环境中运行。
问题来了,我想排除一些文件,然后网上找各种google资料,然后就找到了fileExclusionRegExp这个属性,定义作用是排除文件用的。
那么我就不解了,/[\w\/] (models|collections|views|routers)\/[\w\/]+.js/这样无效,试过其他写法也无效,最后我都用图中这么狠的写法了:/. /还是没效果,求原因,以及怎样实现。

图片描述

==============我真的是分割线===============
顺便一提,我本来是想在r.js里debug的,在r.js里加了个debugger,如图:
图片描述
然后node环境运行:
图片描述
如果哪位大神知道,求原因,拜谢。。

===============问题补充=================
这是Gruntfile.js里grunt-contrib-requirejs的配置:
图片描述

这是requirejs的配置文件:
图片描述

项目目录结构:
图片描述

grunt node.js r.js requirejs JavaScript

耗子2等兵 9 years, 8 months ago

略奇怪,我自己的项目里一直使用 exclude 做过滤的,但是刚去 example-build 里看了下,发现没有 exclude 的介绍了,不知道怎么回事。但确实可以用的。

至于你说的这个 fileExclusionRegExp ,本来看名字还以为和 exclude 功能差不多,但看了文档以后我又不知道它是干嘛得了:


 //When the optimizer copies files from the source location to the
//destination directory, it will skip directories and files that start
//with a ".". If you want to copy .directories or certain .files, for
//instance if you keep some packages in a .packages directory, or copy
//over .htaccess files, you can set this to null. If you want to change
//the exclusion rules, change it to a different regexp. If the regexp
//matches, it means the directory will be excluded. This used to be
//called dirExclusionRegExp before the 1.0.2 release.
//As of 1.0.3, this value can also be a string that is converted to a
//RegExp via new RegExp().

fileExclusionRegExp: /^\./,

竜ヶ峰帝人 answered 9 years, 8 months ago

Your Answer