Grunt plugin for starting the vnu.jar markup checker in server mode. Plays well with grunt-html for faster HTML validation by only starting vnu.jar once, as startup can take a few seconds.
Install this grunt plugin next to your project's Gruntfile.js with:
npm install grunt-vnuserver --save-dev
Then add this line to your project's Gruntfile.js
:
grunt.loadNpmTasks('grunt-vnuserver');
- Type:
Number
- Default: 8888
The port on which to start the server.
all: {
options: {
port: 8877
},
}
- Type:
Boolean
- Default:
false
Whether or not to skip server startup if port is already in use. Task will fail if port is in use and skippable is false.
- Type:
Boolean
- Default:
false
Whether or not to keep the vnu server running even after grunt exists. If false, vnu server is killed when grunt exists.
Consider the following configuration in Gruntfile.js in which the watch
task is set to run htmllint
every time the source file changes.
By starting the validator in server mode once using the vnuserver
task, validations by htmllint
can be performed much faster by simply connecting to this already-running server.
module.exports = function (grunt) {
grunt.initConfig({
vnuserver: {
},
htmllint: {
all: {
options: {
// This option makes grunt-html connect to the vnu server instance.
server: {}
},
src: "app.html"
}
},
watch: {
all: {
tasks: ['htmllint'],
files: "app.html"
}
},
});
grunt.loadNpmTasks('grunt-vnuserver');
grunt.loadNpmTasks('grunt-html');
grunt.loadNpmTasks('grunt-contrib-watch');
grunt.registerTask('default', ['vnuserver', 'watch']);
};
Copyright Bennie Swart. Licensed under the MIT license.