0

我正处于调查 JSCompress for MSBUILD 的初始阶段:http: //msbuildtasks.tigris.org/

对于我的初始测试,我有一些运行此任务的 JS 文件,其中一些文件包括已经缩小的 JS 文件(JQuery 库等),一些文件包含特殊字符。

当任务每次运行时遇到 JS 文件中的特殊字符时,它都会在屏幕上引发错误。我应该如何克服这个错误,以便它忽略特殊字符。

我不想根据文件名上的通配符(例如 **\jquery*.js)排除任何文件,因为开发人员可以将该名称用作其他一些 JS 文件的一部分,然后这些文件将在不缩小的情况下被排除。

有没有办法实现这一点,或者我应该看看其他工具?谢谢 !

4

1 回答 1

0

Use the replace method to replace the special characters with a character entity of your own creation. Then after you have evaluated all the code use the replace method again to revert the special character conversion. I found I had to do this in my Pretty Diff tool because JavaScript cannot evaluate the difference between single and double quotes passed as string literals.

于 2009-09-19T05:31:08.667 回答