# grunt-image-embed-zz

> Grunt task for embedding images as base64 data URIs inside your stylesheets.

Latest version **0.3.1** (published 2014-10-22) · 0 weekly downloads

## Install

```sh
npm install grunt-image-embed-zz
pnpm add grunt-image-embed-zz
yarn add grunt-image-embed-zz
bun add grunt-image-embed-zz
```

Provides the command `grunt-image-embed-zz`.

## Health

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

Positive: no vulnerabilities.

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

Negative: abandoned; low maintenance score.

## Facts

| | |
|---|---|
| Version | 0.3.1 |
| Published | 2014-10-22 |
| First published | 2014-10-22 |
| Weekly downloads | 0 |
| TypeScript types | none |
| Module format | CommonJS |
| Node | >= 0.8.0 |
| Dependencies | 3 |
| Known vulnerabilities | 0 (+3 in 2 direct dependencies) |
| Install scripts | no |
| GitHub stars | 0 |
| Author | zhongzhi107 |
| Maintainers | zhongzhi |
| Keywords | gruntplugin, base64, data URI, css, image |

## Links

- npm: https://www.npmjs.com/package/grunt-image-embed-zz
- Repository: https://github.com/zhongzhi107/grunt-image-embed
- Issues: https://github.com/zhongzhi107/grunt-image-embed/issues
- npm.io page: https://npm.io/package/grunt-image-embed-zz

## Dependencies (3)

- [mime](https://npm.io/package/mime.md) 1.2.x
- [buffers](https://npm.io/package/buffers.md) ~0.1.1
- [request](https://npm.io/package/request.md) ~2.11

## Alternatives

- [style-dictionary](https://npm.io/package/style-dictionary.md) — 2.0M weekly downloads
- [postcss-merge-idents](https://npm.io/package/postcss-merge-idents.md) — 1.7M weekly downloads
- [@fontsource/noto-sans](https://npm.io/package/@fontsource/noto-sans.md) — 93.0K weekly downloads
- [uglifycss](https://npm.io/package/uglifycss.md) — 71.6K weekly downloads
- [mat4-interpolate](https://npm.io/package/mat4-interpolate.md) — 23.3K weekly downloads

## Recent versions

- 0.3.1 (latest) — 2014-10-22

## README

# Grunt Image Embed

This task converts all data found within a stylesheet (those within a url( ... ) declaration) into base64-encoded data URI strings. This includes images and fonts.

Created by Eric Hynds [@erichynds](http://twitter.com/erichynds) with major contributions from [dancingplatypus](https://github.com/dancingplatypus).

## Features

* Supports both local & remote images.
* Ability to specify a size limit. Default is 32kb which is IE8's limit.
* Existing data URIs will be ignored.
* Skip specific images by specifying a directive comment.
* Ability to purge images that have been encoded
* Includes two helpers: `encode_stylesheet` to encode a stylesheet, and `encode_image` to encode an image.

## Getting Started

Install this plugin with the command:

```js
npm install grunt-image-embed
```

Next, add this line to your project's grunt file:

```js
grunt.loadNpmTasks("grunt-image-embed");
```

Lastly, add configuration settings to your grunt.js file (see below).

## Documentation

This task has two required properties, `src` and `dest`. `src` is the path to your stylesheet and `dest` is the file this task will write to (relative to the grunt.js file). If this file already exists **it will be overwritten**.

An example configuration looks like this:

```js
grunt.initConfig({
  imageEmbed: {
    dist: {
      src: [ "css/styles.css" ],
      dest: "css/output.css",
      options: {
        deleteAfterEncoding : false
      }
    }
  }
});
```

### Optional Configuration Properties

ImageEmbed can be customized by specifying the following options:

* `maxImageSize`: The maximum size of the base64 string in bytes. This defaults to `32768`, or IE8's limit. Set this to `0` to remove the limit and allow any size string.
* `baseDir`: If you have absolute image paths in your stylesheet, the path specified in this option will be used as the base directory.
* `deleteAfterEncoding`: Set this to true to delete images after they've been encoded. You'll want to do this in a staging area, and not in your source directories.  Be careful.
* `disableRemoteImage`: Set this to true to disable remote image file embed.

### Skipping Images

Specify that an image should be skipped by adding the following comment directive *after* the image:

```css
background: url(image.gif); /*ImageEmbed:skip*/
```

## Compatibility

Version >= 0.3.0 of this plugin is compatible with Grunt 0.4.x. Versions 0.0.1 through 0.2.0 are only compatible with Grunt 0.3.x.

## License

Copyright (c) 2013 Eric Hynds (@erichynds)
Licensed under the MIT License.

---
_Source: https://npm.io/package/grunt-image-embed-zz · Machine-readable twin of the npm.io package page. Health data is recomputed on every publish._
