10

这是一个菜鸟问题。

我想grunt.js用作我的网络项目的构建工具。可以grunt.js用来验证我的HTML/CSS文件吗?你有这样一个grunt.js文件的例子吗?

4

3 回答 3

7

There is another plugin that seems to be updated more often and does not require java. grunt-html-validation. It has a number of options and has been working great for me. You can install and use it like this:

npm install grunt-html-validation --save-dev

Then put something like this in the initconfig of your Gruntfile.js

and this in appropriate places in your Gruntfile.js

grunt.loadNpmTasks('grunt-html-validation');
grunt.registerTask("default", ["validation"]);

There is also a number of useful options including the ability to relax errors based on a regular expression (could be useful for AngularJS for example) and the ability to save a report.

于 2014-01-14T16:06:44.643 回答
4

您可以使用 grunt 插件grunt-html。请注意,您需要在计算机上安装 Java 才能使用它。这对我来说很有用。

于 2012-07-25T13:56:59.147 回答
2

到目前为止,似乎有两个流行的 HTML 验证插件:

grunt-html-validation使用 W3C 标记验证服务并grunt-html使用基于 java 的 The Nu HTML Checker 的本地副本。

它们都运行良好并且具有非常相似的选项,因此归结为您是要等待外部服务调用还是等待本地 Java 应用程序。

于 2015-03-26T15:54:46.043 回答