# base64-inline-loader

> A Base64 loader for Webpack

Latest version **2.0.1** (published 2021-09-17) · MIT license · 0 weekly downloads

## Install

```sh
npm install base64-inline-loader
pnpm add base64-inline-loader
yarn add base64-inline-loader
bun add base64-inline-loader
```

## Health

**Score 15/100 (F)** — status: abandoned.

Positive: no vulnerabilities.

Warnings: low downloads; no types; no esm support.

Negative: abandoned; low maintenance score.

## Facts

| | |
|---|---|
| Version | 2.0.1 |
| Published | 2021-09-17 |
| First published | 2016-10-16 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | none |
| Module format | CommonJS |
| Node | >=6.2 |
| Dependencies | 2 |
| Unpacked size | 4.9 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| GitHub stars | 3 |
| Author | Aleksandr Abashkin |
| Maintainers | monolithed |
| Keywords | webpack, base64 |

## Links

- npm: https://www.npmjs.com/package/base64-inline-loader
- Repository: https://github.com/monolithed/base64-inline-loader
- Homepage: https://github.com/monolithed/base64-inline-loader#readme
- Issues: https://github.com/monolithed/base64-inline-loader/issues
- npm.io page: https://npm.io/package/base64-inline-loader

## Dependencies (2)

- [mime-types](https://npm.io/package/mime-types.md) ^2.1.32
- [loader-utils](https://npm.io/package/loader-utils.md) ^2.0.0

## Alternatives

- [flatbuffers](https://npm.io/package/flatbuffers.md) — 6.0M weekly downloads
- [jwt-simple](https://npm.io/package/jwt-simple.md) — 259.5K weekly downloads
- [@exodus/patch-broken-hermes-typed-arrays](https://npm.io/package/@exodus/patch-broken-hermes-typed-arrays.md) — 28.5K weekly downloads
- [@native-to-anchor/buffer-layout](https://npm.io/package/@native-to-anchor/buffer-layout.md) — 12.2K weekly downloads
- [binary-parser-encoder](https://npm.io/package/binary-parser-encoder.md) — 5.3K weekly downloads

## Recent versions

- 2.0.1 (latest) — 2021-09-17
- 2.0.0 — 2021-09-17
- 1.1.1 — 2018-03-08
- 1.1.0 — 2017-02-07
- 1.0.1 — 2017-02-04
- 1.0.0 — 2017-02-04
- 0.0.2 — 2016-10-17
- 0.0.1 — 2016-10-16

## README

# 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

```js

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

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

body {
    background-image: url('./image.png');
}
```

#### Output

```css
@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.<br />

```typescript
{
    use: {
        loader: 'base64-inline-loader',
        options: {
            limit: 1000
        }
    }
}
```

* `typeMapper` — use this option to fix your non-standard MIME types<br />

```js
{
    use: [
        {
            loader: 'base64-inline-loader',
            options: {
                typeMapper: {
                    'text/less': 'text/css'
                }
            }
        },
        'less-loader'
    ]
}
```

```html
<link rel="stylesheet" href="data:text/less;charset=utf-8;base64,Lm54dC1lcnJvci1wYW..." />
````

## Tests

```
npm test
```

---
_Source: https://npm.io/package/base64-inline-loader · Machine-readable twin of the npm.io package page. Health data is recomputed on every publish._
