Skip to content

Instantly share code, notes, and snippets.

@Yoplitein
Created August 26, 2018 08:47
Show Gist options
  • Save Yoplitein/ab42066b7a86cc3cd07763935bf68285 to your computer and use it in GitHub Desktop.
Save Yoplitein/ab42066b7a86cc3cd07763935bf68285 to your computer and use it in GitHub Desktop.
Webpack loader for binary files (doesn't munge content by storing in strings)
const fs = require("fs");
module.exports = function(source)
{
const buffer = fs.readFileSync(this.resourcePath)
return `module.exports = Uint8Array.from([${buffer.toJSON().data}]);`;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment