如何配置Web Essentials 2013以忽略文件? [英] How can I configure Web Essentials 2013 to ignore files?

查看:96
本文介绍了如何配置Web Essentials 2013以忽略文件?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在VS 2013(更新1)中安装了新的MVC 5.1 Web应用程序项目,并安装了Web Essential 2013(截至今天).构建项目后,Web Essentials会扫描javascript文件,并将发现的任何问题发布到输出窗口中.对于一个全新的MVC 5.1项目,它会生成超过11,000条消息-确实没有用.

I have a fresh MVC 5.1 web app project in VS 2013 (Update 1) w/ Web Essential 2013 (latest as of today) installed. After building the project, Web Essentials scans for javascript files and post messages to the output window for any issues it finds. For a brand new MVC 5.1 project, it generates over 11,000 messages - not really useful.

我尝试了两种方法来使其默认情况下忽略新MVC 5项目随附的有问题的javascript文件:

I've tried two methods to get it to ignore the offending javascript files that are included with new MVC 5 projects by default:

  1. 使用了Web Essentials>编辑全局JSCS设置命令来打开我的用户配置文件目录中的.jscs.json文件.然后将"excludeFiles"属性修改为["test/data/ .js","Scripts/jquery .js"].

在我的Scripts文件夹中使用"jquery * .js"创建了一个.jshintignore文件.

Created a .jshintignore file in my Scripts folder with "jquery*.js".

这两种方法都不会对生成的JSCS消息产生任何影响.我做错什么了吗,或者这是Web Essentials的问题?

Neither of these methods has had any impact on the JSCS messages generated. Am I doing something wrong, or is this an issue with Web Essentials?

推荐答案

更新4:

最新的Web Essentials 2013 1.9具有对皮棉跑步者更好的忽略逻辑",所有问题均已清除.您现在可以打开在构建中运行".它具有针对普通js库和精简js的默认忽略规则.以下excludeFiles配置仍然有效,但不再需要.

The newest Web Essentials 2013 1.9 has "Better ignore logic for the lint runners", all the problems are cleared. You can turn on "Run on build" now. It has default ignore rule for common js library and minified js. The following excludeFiles config still works, but not necessary anymore.

更新3:

https://github.com/madskristensen/WebEssentials2013/issues/603 .

如果不需要JSHint和JSCS的功能,只需转到工具-选项-Web Essentials-JavaScript",将在构建时运行"和在保存时运行"设置为False.

If you don't need JSHint and JSCS's function, just go to "Tools - Options - Web Essentials - JavaScript", set "Run on build" and "Run on save" to False.

如果要使用它们,请将在构建时运行"保持为False,将在保存时运行"设置为True.预览,打开和保存时,所有js均为JSHint和JSCS.通过此更改,您可以成功构建而不会降低速度.错误列表将仅填充当前打开的js的JSHint和JSCS项.

If you wish to use them, keep "Run on build" False, set "Run on save" to True. All js will be JSHint and JSCS while preview, open and save. With this change, you can build successfully without slow down. Error list will only be filled with currently opened js's JSHint and JSCS items.

默认情况下,JSHint不会在所有缩小的和某些常见的js库上运行,但是JSCS将始终运行.使用JSCS时,使用精简版js可能会使您延迟大约serval秒.如果您不想等待,请转到"Web Essentials-编辑全局JSCS设置".更改

By default setting, JSHint won't run on all minified and some common js library, but JSCS will run always. While JSCS, it may delay you about serval seconds with minified js. If you don't wanna wait, then go to "Web Essentials - Edit global JSCS settings". Change

"excludeFiles": ["test/data/*.js"],

进入

"excludeFiles": ["**/*.min.js", "**/*.debug.js", "**/*.intellisense.js", "**/*-vsdoc.js"],

仅在缩小的js上跳过JSCS.或更改为

to skip JSCS only on minified js. Or change to

"excludeFiles": ["**"],

要完全停止JSCS,只能保持JSHint运行.

to stop JSCS totally, only keep JSHint running.

当然,您可以编写自己的规则以排除不需要的规则.只需将双星放在开头,使用"/"代替"\",其他部分仅将单星用作通配符.类似于"**/Scripts/*.js".

Of cause you can write your own rule to exclude those you don't need. Just put double stars at the beginning, use '/' instead of '\', other part just use single star for wildcard. Like "**/Scripts/*.js".

使用exclude规则,它仍将为每个js生成一个xml信息项,稍后(希望如此)将对其进行修复,但是最后您可以开始编码了.

With exclude rule, it will still generate an xml information item for each js, that will be fix later (hopefully), but at last you can start coding.

最后,您可以升级到1.8.5,但是它只会阻止在构建时运行"的运行. 运行时保存"仍然需要这些设置.因此,它不会改变我在这里说的话.

At last, you can upgrade to 1.8.5, but it only stop "Run on build" from running. "Run on save" still need these settings. So it don't change what I say here.

希望这些信息正确无误,对当前版本为1.8和1.8.5有所帮助.

Hope these informations are right and helpful, with current version of 1.8 and 1.8.5.

更新1:

安装新版本1.8.5.它将停止在构建时运行"功能.这意味着即使您打开它,它也不会在构建中运行.但是在保存时运行True"将仍然并且实际上在预览,打开和保存时运行. excludeFiles的右相对模式为**/Script/**.

Install new version 1.8.5. It will stop "Run on build" function. That means even you turn it on, it will not run on build. But "Run on save True" will still and actually run on preview, open and save. The right relative pattern of excludeFiles is **/Script/**.

因此,精简js的命令排除规则将为:

So the recommand exclude rule for minified js will be:

    "excludeFiles": ["**/Scripts/**.min.js", "**/Scripts/**.debug.js", "**/Scripts/**.intellisense.js", "**/Scripts/**-vsdoc.js"],

或者只是使用**/Script/**将它们全部排除.

Or just use **/Script/** to exclude them all.

根据上的JSHint/JSCS错误,<?xml问题将在下一版本中修复.最小文件和其他文件?.因此,此模式应该是最终正确的选择,其中一个问题应该并且将在下一Web Essentials版本中得到解决.或者,也许下一个WE将提供一个很好的默认excludeFiles规则.

The <?xml problem will be fix by next version, according to JSHint/JSCS Errors on .min files and others?. So this pattern should be the final right one, with one problem that should and will be fix by next Web Essentials version. Or maybe next WE will provide a good default excludeFiles rule.

更新2:

更好的一个:

"excludeFiles": ["**/*.min.js", "**/*.debug.js", "**/*.intellisense.js", "**/*-vsdoc.js"],

排除所有缩小的js,无论它在哪里.

to exclude all minified js no matter where it is.

我发现的简单方法是转到工具-选项-Web Essentials-JavaScript",将在构建/保存时运行"设置为False.

The easy way I found is go to "Tools - Options - Web Essentials - JavaScript", set Run on Build/Save to False.

另一种方法是转到"Web Essentials-编辑全局JSCS设置",以设置excludeFiles.

Another method is go to "Web Essentials - Edit global JSCS settings", to set excludeFiles.

但是多个excludeFiles是错误的语法.应该使用["a","b"]语法.

But multiple excludeFiles is wrong syntax. Should use [ "a", "b"] syntax.

并且应该使用绝对路径(在全局设置中使用时)和路径分隔符"/",不允许使用"\".

And should use absolute path, (while setting in global?) with path divider '/', '\' is not allowed.

子目录没有用,您应该指定每个单独的路径.

Sub directory is no use, you should specify every single path.

所以这样的有效设置:

"excludeFiles": ["C:/Solution/Project/Scripts/*", "C:/Solution/Project/Scripts/kendo/*"]

但是这种方式会为每个js文件生成另一个Build错误:

But this way will generate another Build error per js file:

JSCS parse error: <?xml version="1.0" encoding="utf-8"?>
<checkstyle version="4.3">
</checkstyle>

每个js文件的信息项:

And information item per js file:

<?xml version="1.0" encoding="utf-8"?>
<checkstyle version="4.3">
</checkstyle>

我不知道如何避免.因此,也许最好的方法只是第一种简单的方法.

I don't know how to avoid it. So maybe the best way is just the first easy way.

这篇关于如何配置Web Essentials 2013以忽略文件?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆