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

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的配置文件:

项目目录结构:


略奇怪,我自己的项目里一直使用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: /^\./,

过去这么长时间了依然没人能答上来,我也是很无语。
我自己来吧。
r.js确实有一个 fileExclusionRegExp 参数,而且官方文档也是说用来排除文件或者路径用的。
但,
确实没有个卵用。
不过想想,好像不生效也对吧,毕竟r.js就是为了把所有依赖的文件按顺序合并成一个文件的,万一因为排除了某个文件导致页面报错呢?
现在纠结的点是,既然不需要这个参数了,为什么官方还提供呢?提供了居然还没有用。。不知道他们都在想些什么。

【热门文章】
【热门文章】