Skip to content

Commit

Permalink
Build: Generate sub-resource integrity hashes of the distribution fil…
Browse files Browse the repository at this point in the history
  • Loading branch information
Arkni authored and staabm committed May 29, 2018
1 parent a355a0f commit a3925cd
Show file tree
Hide file tree
Showing 3 changed files with 28 additions and 2 deletions.
24 changes: 23 additions & 1 deletion Gruntfile.js
Original file line number Diff line number Diff line change
Expand Up @@ -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"
]
}
}
} );

Expand All @@ -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" ] );

};
5 changes: 4 additions & 1 deletion build/release.js
Original file line number Diff line number Diff line change
Expand Up @@ -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"
]);
},

Expand Down
1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -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"
},
Expand Down

0 comments on commit a3925cd

Please sign in to comment.