Simple JSONP wrapper Gulp Plugin.
npm install gulp-jsonp
var gjsonp = require("gulp-jsonp");
/**
* Build JS
*/
gulp.task('js', function () {
gulp.src(['./src/**/*.html'])
.pipe(gjsonp({
callback: "__myJSONPCallbackFunction",
key: "optionalFilePrefix_"
}))
.pipe(gulp.dest('./dist/'));
});
The plugin will rename files to have a .js extension, and wrap the contents in an object like so:
__myJSONPCallbackFunction({"filename":"optionalFilePrefix_index.html","contents":"[BASE64 ENCODED CONTENTS]"});