1.1.0 • Published 6 years ago
gulp-generate-image-data-uri v1.1.0
gulp-generate-image-data-uri
Does exactly as it says on the tin. A gulp plugin to generate datauris for images.
Install
I use Yarn, and love it. I totally recommend using it as well!
To install via Yarn:
$ yarn add gulp-generate-image-data-uri -D
To install via npm:
$ npm install gulp-generate-image-data-uri -D
Usage
As with most Gulp plugins, this is relatively easy to set up.
const gulp = require('gulp');
const dataURI = require('gulp-generate-image-data-uri');
gulp.task('default', () =>
gulp.src('src/img.jpg')
.pipe(dataURI())
.pipe(gulp.dest('dist'))
);
This will output a file, img.txt, which contains the data-uri.
API
datauri(options)
options
isJS
Type: boolean
Default: false
Outputs datauris to JS instead, one defintion per file. The format being:
const camelCaseFileName = 'dataURI';
Credit
This plugin would not be possible without the Node module datauri, which is used to generate the datauris
License
MIT © Aaron Kelly-Barker