7.0.1 • Published 6 months ago

postcss-image-inliner v7.0.1

Weekly downloads
24,074
License
MIT
Repository
github
Last release
6 months ago

PostCSS Image Inliner Build Status

PostCSS plugin to inline local/remote images.

.foo {
  /* Input example */
  background-image: url('https://placehold.it/10x10');
}
.foo {
  /* Output example */
  background-image: url('data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAo ... ORK5CYII=');
}

Installation

npm i -D postcss postcss-image-inliner

Usage

const postcss = require('postcss');
const imageInliner = require('postcss-image-inliner');
const opts = {
  assetPaths: [], // List of directories where the inliner should look for assets
  maxFileSize: 10240, // Sets a max file size (in bytes)
};

postcss([imageInliner(opts)]);

See PostCSS docs for examples for your environment.

Options

assetPaths

  • Type: array
  • Default: [process.cwd()]
  • Example: ['http://domain.de/', 'http://domain.de/styles', 'app/images', '**/images/']
  • Required: false

List of directories/URLs where the inliner should start looking for assets. You can define local directories (globs supported) or URLs.

maxFileSize

  • Type: int
  • Default: 10240
  • Example: 0
  • Required: false

Sets a max file size (in bytes) for inlined images. Set to 0 to disable size checking.

largeFileCallback

  • Type: function
  • Default: undefined
  • Example: function (file) { console.log('big file found:', file.path); return file.path }
  • Required: false

Allows you to act on large files and change the url if you'd like. Make sure you have strict set to false when using this.

b64Svg

  • Type: bool
  • Default: false
  • Required: false

Use Base64 encoding for SVGs.

svgoPlugins

  • Type: array
  • Default: []
  • Required: false

Use custom svgo configuration for svg optimization

strict

  • Type: bool
  • Default: false
  • Required: false

Fail on error.

filter

  • Type: regex
  • Default: /^(background(?:-image)?)|(content)|(cursor)/
  • Required: false

Regex to match the CSS properties to be inlined.

6.2.0

7 months ago

7.0.0

7 months ago

7.0.1

6 months ago

6.1.0

1 year ago

6.0.1

2 years ago

6.0.0

2 years ago

5.0.0

3 years ago

4.0.4

3 years ago

4.0.3

4 years ago

4.0.2

4 years ago

4.0.1

4 years ago

4.0.0

4 years ago

3.0.9

4 years ago

2.0.3

4 years ago

3.0.8

4 years ago

3.0.7

4 years ago

3.0.6

4 years ago

3.0.5

5 years ago

3.0.4

5 years ago

2.0.2

5 years ago

3.0.3

5 years ago

2.0.1

5 years ago

3.0.2

5 years ago

3.0.1

5 years ago

3.0.0

5 years ago

2.0.0

6 years ago

1.0.6

7 years ago

1.0.5

7 years ago

1.0.4

7 years ago

1.0.3

7 years ago

1.0.2

7 years ago

1.0.1

8 years ago

1.0.0

8 years ago

0.3.1

8 years ago

0.3.0

8 years ago

0.2.0

8 years ago

0.1.4

9 years ago

0.1.3

9 years ago

0.1.2

9 years ago

0.1.1

9 years ago

0.1.0

9 years ago