diff --git a/Gruntfile.js b/Gruntfile.js index a444d75c9..c5fe1df1e 100644 --- a/Gruntfile.js +++ b/Gruntfile.js @@ -171,6 +171,27 @@ grunt.initConfig( { } ] } + }, + + // Generate the sub-resource integrity hashes of the distribution files + sri: { + options: { + algorithms: [ "sha256", "sha384", "sha512" ], + + // The target json file + dest: "dist/jquery-validation-sri.json", + + // Stringify the JSON output in a pretty format + pretty: true + }, + + all: { + src: [ + "dist/jquery.validate.{min.js,js}", + "dist/additional-methods.{min.js,js}", + "dist/localization/*.js" + ] + } } } ); @@ -183,9 +204,10 @@ grunt.loadNpmTasks( "grunt-contrib-watch" ); grunt.loadNpmTasks( "grunt-jscs" ); grunt.loadNpmTasks( "grunt-contrib-copy" ); grunt.loadNpmTasks( "grunt-text-replace" ); +grunt.loadNpmTasks( "grunt-sri" ); grunt.registerTask( "default", [ "concat", "copy", "jscs", "jshint", "qunit" ] ); -grunt.registerTask( "release", [ "default", "uglify", "replace", "compress" ] ); +grunt.registerTask( "release", [ "default", "uglify", "replace", "compress", "sri" ] ); grunt.registerTask( "start", [ "concat", "watch" ] ); }; diff --git a/build/release.js b/build/release.js index 1041c7951..7ba8a04fc 100644 --- a/build/release.js +++ b/build/release.js @@ -42,7 +42,10 @@ Release.define({ "dist/additional-methods.js", "dist/additional-methods.min.js", "dist/jquery.validate.js", - "dist/jquery.validate.min.js" + "dist/jquery.validate.min.js", + + // The sub-resource integrity hashes of the distribution files + "dist/jquery-validation-sri.json" ]); }, diff --git a/package.json b/package.json index b95061195..4b1e91017 100644 --- a/package.json +++ b/package.json @@ -49,6 +49,7 @@ "grunt-contrib-uglify": "1.0.1", "grunt-contrib-watch": "1.0.0", "grunt-jscs": "2.8.0", + "grunt-sri": "0.2.0", "grunt-text-replace": "0.4.0", "qunitjs": "2.3.3" },