Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to validate HTML/CSS files with grunt.js?

This is a noob question.

I would like to use grunt.js as a build tool for my web project. Can use grunt.js to validate my HTML/CSS files? Do you have an example of such a grunt.js file?

like image 726
Michael Avatar asked Jul 18 '12 14:07

Michael


1 Answers

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.

like image 63
SnapShot Avatar answered Oct 25 '22 09:10

SnapShot