Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

base64-inline-loader

Package Overview
Dependencies
Maintainers
1
Versions
8
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

base64-inline-loader

A Base64 loader for Webpack

  • 2.0.1
  • latest
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
16K
decreased by-33.76%
Maintainers
1
Weekly downloads
 
Created
Source

base64-inline-loader

A Base64 loader for webpack. Encodes all binary files to Base64 strings.

Installation

npm

npm install base64-inline-loader --save

or

yarn

yarn add -D base64-inline-loader

Usage

Config

const path = require('path');

module.exports = [
    {
        ...

        module: {
            rules: [
                {
                    test: /\.(jpe?g|png|ttf|eot|svg|woff(2)?)(\?[a-z0-9=&.]+)?$/,
                    use: ['base64-inline-loader']
                }
            ]
        }

        ...
    }
];
Input
@font-face {
    font-family: 'icons';
    src: url('./icon.woff');
}

body {
    background-image: url('./image.png');
}
Output
@font-face {
    font-family: 'icons';
    src: url('data:application/x-font-woff;charset=utf-8;base64,[BASE_64_STRING...]')
}

body {
    background-image: url('data:application/png;charset=utf-8;base64,[BASE_64_STRING...]');
}

Options

  • limit — The limit can be specified with a query parameter.
{
    use: {
        loader: 'base64-inline-loader',
        options: {
            limit: 1000
        }
    }
}
  • typeMapper — use this option to fix your non-standard MIME types
{
    use: [
        {
            loader: 'base64-inline-loader',
            options: {
                typeMapper: {
                    'text/less': 'text/css'
                }
            }
        },
        'less-loader'
    ]
}
<link rel="stylesheet" href="data:text/less;charset=utf-8;base64,Lm54dC1lcnJvci1wYW..." />

Tests

npm test

Keywords

FAQs

Package last updated on 17 Sep 2021

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc