7.3.1 • Published 1 year ago

postcss-inline-base64 v7.3.1

Weekly downloads
357
License
MIT
Repository
github
Last release
1 year ago

PostCSS Inline Base64

Node.js CI Coverage Status Snyk badge

PostCSS plugin used to replace value inside of url function to base64

Usage

See the example below

import postcssInlineBase64 from 'postcss-inline-base64'

postcss([
  postcssInlineBase64(options),
])

If you are using CommonJS module:

postcss([
  require('postcss-inline-base64')(options),
])

Options

NameTypeDefaultDescription
baseDirstringprocess.cwd()Path to load files

Example

Use the syntax below inside url() function:

Variations:

 - b64---{file}---
 - b64---'{file}'---
 - b64---"{file}"---
 - 'b64---{file}---'
 - "b64---{file}---"

input

:root {
  --image: 'b64---./example.gif---';
}

@font-face {
  font-family: 'example';
  src: url('b64---./example.woff---') format('woff'), url('b64---./example.woff2---') format('woff2');
  font-weight: normal;
  font-style: normal;
}

body {
  background-color: gray;
  background-image: url(var(--image));
}

.notfound {
  background-image: url('b64---https://file.not/found.png---');
}

.ignore {
  background-image: url('https://cdn.lagden.in/mask.png');
}

output

:root {
  --image: 'data:image/png;charset=utf-8;base64,iVBORw0K...SuQmCC';
}

@font-face {
  font-family: 'example';
  src: url('data:font/woff;charset=utf-8;base64,d09...eLAAAA==') format('woff'), url('data:font/woff2;charset=utf-8;base64,d09...eLAAAA==') format('woff2');
  font-weight: normal;
  font-style: normal;
}

body {
  background-color: gray;
  background-image: url(var(--image));
}

.notfound {
  background-image: url('https://file.not/found.png');
}

.ignore {
  background-image: url('https://cdn.lagden.in/mask.png');
}

See PostCSS docs for examples for your environment.

Donate ❤️

  • BTC: bc1q7famhuj5f25n6qvlm3sssnymk2qpxrfwpyq7g4
  • PIX: lagden@gmail.com

License

MIT © Thiago Lagden

7.3.1

1 year ago

7.3.0

1 year ago

7.2.2

2 years ago

7.2.1

2 years ago

7.2.0

2 years ago

7.1.0

3 years ago

7.0.0

3 years ago

6.2.1

3 years ago

6.2.0

4 years ago

6.1.0

4 years ago

6.0.0

4 years ago

5.0.0

4 years ago

4.1.0

4 years ago

4.0.0

6 years ago

3.0.3

6 years ago

3.0.2

6 years ago

3.0.1

6 years ago

3.0.0

6 years ago

2.2.1

8 years ago

2.2.0

8 years ago

2.1.0

8 years ago

2.0.0

8 years ago

1.0.0

8 years ago