Skip to content

Build: Generate sub-resource integrity hashes of the distribution files #2082

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 2 commits into from
May 29, 2018
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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