Skip to content

Instantly share code, notes, and snippets.

@taylor8294
Created February 3, 2019 20:05
Show Gist options
  • Select an option

  • Save taylor8294/75e665ed0acb1bd93bf0e5628619d4b7 to your computer and use it in GitHub Desktop.

Select an option

Save taylor8294/75e665ed0acb1bd93bf0e5628619d4b7 to your computer and use it in GitHub Desktop.
// Postinstall script to ensure jQuery loads in the window object when using in Electron (not in module.exports)
// See https://stackoverflow.com/questions/32621988/electron-jquery-is-not-defined
const fs = require('fs');
const f_jquery = 'node_modules/jquery/dist/jquery.min.js';
fs.readFile(f_jquery, 'utf8', function (err, contents) {
if (err) {
return console.log(err);
}
var result = contents.replace('"use strict";"object"==typeof module&&"object"==typeof module.exports?', '"use strict";false?');
fs.writeFile(f_jquery, result, 'utf8', function (err) {
if (err) return console.log(err);
});
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment