webpack binary-loader

raw JSON →
0.0.1 verified Sat Apr 25 auth: no javascript deprecated

A webpack loader that returns a file's content as a binary string. Adapted from raw-loader. Version 0.0.1, no recent updates. Key differentiators: allows importing binary files as strings without base64 encoding. No active maintenance, use raw-loader or file-loader with encoding options instead.

error Module not found: Error: Can't resolve 'binary-loader' in /path
cause Missing npm install or local path issue.
fix
Run 'npm install binary-loader' and ensure it's in node_modules.
error Module build failed: loader 'binary' not found
cause Loader name typo.
fix
Use 'binary-loader' or 'binary!./file.bin' (with exclamation) in require.
deprecated This package is no longer maintained and has limited functionality.
fix Use raw-loader or file-loader instead.
breaking Works only with legacy webpack 1/2; incompatible with webpack 4+ without additional configuration.
fix Use webpack 4+ compatible alternatives.
gotcha Output is a binary string (not Buffer or ArrayBuffer), which may cause issues with binary data handling.
fix Consider using raw-loader or file-loader for proper binary handling.
npm install binary-loader
yarn add binary-loader
pnpm add binary-loader

Shows how to configure webpack to use binary-loader for .bin files and import them as binary strings.

// webpack.config.js
module.exports = {
  module: {
    rules: [
      {
        test: /\.bin$/,
        use: 'binary-loader'
      }
    ]
  }
};

// app.js
var binaryData = require('./file.bin');
console.log(binaryData); // binary string of file content