简体   繁体   English

如何使Visual Studio停止“编译”.js和.css文件

[英]How to make Visual Studio stop “compiling” .js and .css files

I use Visual Studio as my editor for .css and .js files.. It REALLY SUCKS especially with .js files since it insists on indenting them in a very weird way, but I find it convenient that the first alt-tab is always the browser instead of another editor, and that ctrl-tab is always either the code file or the css/js. 我使用Visual Studio作为.css和.js文件的编辑器。它真的很糟糕,尤其是.js文件,因为它坚持以非常奇怪的方式缩进它们,但我发现第一个alt-tab始终是浏览器而不是另一个编辑器,并且ctrl-tab始终是代码文件或css / js。

Anyways, in all its radiant wisdom it decides to check them for syntax errors as well and every time I compile my project it gives several "errors" that push down the real errors of the compilation, so every time I make a syntax error in a code file I have to scroll down through all the js/css errors to see what's wrong. 无论如何,它的所有光芒四射的智慧决定检查它们的语法错误,每次我编译我的项目时它会产生几个“错误”,从而压低编译的真实错误,所以每次我在一个语法错误中代码文件我必须向下滚动浏览所有js / css错误,看看有什么问题。

Examples of such errors (that aren't really errors) are: 此类错误(不是真正的错误)的示例如下:

Error   7   Validation (CSS 2.1): 'text-rendering' is not a known CSS property name.
Error   8   Validation (CSS 2.1): 'opacity' is not a known CSS property name.

The situation also got much worse recently, since it now keeps parsing a .js file as a .css file for some reason, so I get errors such as: 最近情况也变得更糟,因为它现在因为某种原因将.js文件解析为.css文件,所以我得到如下错误:

Error   1   Unexpected character sequence. Expected a selector for the style rule.  E:\Dev\anacletus\Static\set_focus.js    2
Error   2   Unexpected character sequence. Expected a property name for the " : " declaration. E:\Dev\anacletus\Static\set_focus.js    3
Error   3   Validation (CSS 2.1): 'set-focus' is not a known CSS property name. E:\Dev\anacletus\Static\set_focus.js    3

I even deleted that particular file from the solution (it's not there anymore anywhere), but it keeps parsing it anyway. 我甚至从解决方案中删除了该特定文件(它不再存在于任何地方),但无论如何它仍在解析它。

In short, how can I disable this feature? 简而言之,我该如何禁用此功能?

Enter the options through 输入选项

Tools > Options 工具>选项

If it isn't checked, check the "Show all settings" box at the bottom of that window. 如果未选中,请选中该窗口底部的“显示所有设置”框。

In the tree to the left, choose: 在左侧的树中,选择:

Text Editor > CSS > CSS Specific 文本编辑器> CSS> CSS特定

Uncheck "Detect Errors" . 取消选中“检测错误” Then, choose: 然后,选择:

Text Editor > JScript > Miscellaneous 文本编辑器> JScript>杂项

Uncheck "Show syntax errors" . 取消选中“显示语法错误”

You can also change how it indents each type of code too, in the various settings in those "Text Editor" sub-options. 您还可以在“文本编辑器”子选项的各种设置中更改缩进每种类型代码的方式。

I know, this question is old, but I have an update (for Visual Studio 2010): 我知道,这个问题很老,但我有一个更新(对于Visual Studio 2010):

The accepted solution has a big disadvantage: It disables all syntax checking of CSS and JScript. 接受的解决方案有一个很大的缺点:它禁用CSS和JScript的所有语法检查。 If you still want to have meaningful warnings , you can do the following workaround. 如果您仍希望获得有意义的警告 ,则可以执行以下解决方法。 It will treat errors as warnings , and it will do css validation on css V3.0 level rather than on (old) css V2.1: 它会将错误视为警告 ,它将在css V3.0级别而不是(旧)css V2.1上进行css验证:

  1. Close Visual Studio 关闭Visual Studio
  2. Download and install the web standards package for Visual Studio 2010 SP 1 下载并安装Visual Studio 2010 SP 1Web标准包
  3. Open the path (on 32 bit machines, it is Program Files ) 打开路径(在32位机器上,它是Program Files

    C:\\Program Files (x86)\\Microsoft Visual Studio 10.0\\Common7\\Packages\\1033\\schemas\\CSS C:\\ Program Files(x86)\\ Microsoft Visual Studio 10.0 \\ Common7 \\ Packages \\ 1033 \\ schemas \\ CSS

  4. Backup CSS21.xml for safety reasons 出于安全原因备份CSS21.xml
  5. Overwrite CSS21.xml by the file CSS30.xml (in the same directory) 用文件CSS30.xml覆盖CSS21.xml (在同一目录下)
  6. Open Visual Studio. 打开Visual Studio。 In Text Editor settings, (re-)enable "Show syntax errors". 在文本编辑器设置中,(重新)启用“显示语法错误”。 Ensure you have checked "as warnings" too. 确保您也检查了“警告”。
From now on syntax checking of CSS is done on 3.0 level (although it appears in Visual Studio now as 2.1), and you're getting warnings instead of errors if the syntax checker finds anything. 从现在开始,CSS的语法检查在3.0级别完成(虽然它现在在Visual Studio中显示为2.1),如果语法检查器发现任何内容,您将收到警告而不是错误。

(Note that the Style Sheet toolbar only allows to enable CSS 3.0 checking for css files, not for HTML. Hence, this fix is needed if you want to keep syntax checking) (请注意,样式表工具栏仅允许启用CSS 3.0检查css文件,而不是HTML。因此,如果要保持语法检查,则需要此修复)

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 编译时Visual Studio中的CSS样式错误 - CSS style errors in Visual Studio while compiling 通过自定义控件添加css时如何停止Visual Studio css intellisense中断 - How to stop Visual Studio css intellisense breaking when css is added via a custom control Visual Studio嵌套html,css和ts文件 - Visual Studio Nesting html,css and ts files Visual Studio Code 不会将 CSS 样式表和 JS 文件添加到 HTML 代码 - Visual Studio Code doesn't add CSS Stylesheets and JS-Files to HTML code 用于CSS和JS的Visual Studio代码比较(用于合并) - Visual Studio Code Compare (for merging) for CSS and JS 通过最小化CSS和JS编译Visual Studio项目 - Compile Visual Studio project by minifying css and js 在编辑css文件时,如何强制Visual Studio遵循自定义CSS模板? - How can I force Visual Studio to follow a custom CSS template when I edit my css files? 是否有可能阻止Visual Studio 2008无法构建CSS错误? - Is it possible to stop Visual Studio 2008 from failing to build on CSS errors? 如何制作bundle.css和bundle.js文件 - How to make bundle.css and bundle.js files Visual Studio 2013 可以从 .less 文件生成 CSS 文件吗? - Can Visual Studio 2013 generate CSS files from .less files?
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM