在线时间:8:00-16:00
迪恩网络APP
随时随地掌握行业动态
扫描二维码
关注迪恩网络微信公众号
开源软件名称(OpenSource Name):adam-lynch/gulp-image-data-uri开源软件地址(OpenSource Url):https://github.com/adam-lynch/gulp-image-data-uri开源编程语言(OpenSource Language):CoffeeScript 89.4%开源软件介绍(OpenSource Introduction):gulp-image-data-uriA Gulp plugin for converting images to inline data-URIs. Intended to be a simple single-purpose wrapper for heldr/datauri (well, datauri.template). Installationnpm install gulp-image-data-uri Usage for Gulp ^4.0.0const gulp = require('gulp'),
imageDataURI = require('gulp-image-data-uri');
// path variables
var imgSrc = 'src/img/*',
cssDist = 'dist/css/',
// the task
exports.datauri = function () {
return src (imgSrc)
.pipe(imageDataURI())
.pipe(dest(cssDist))
} The Ol' fashion wayReminder: The var gulp = require('gulp');
var imageDataURI = require('gulp-image-data-uri');
gulp.task('prepare', function() {
gulp.src('./images/*')
.pipe(imageDataURI())
.pipe(gulp.dest('./dist'));
});
gulp.task('default', ['prepare']); For example output, see test/expected. See Examples for more information. OptionscustomClassAn optional function. If omitted, the class added is just the file's basename. The function is called with two arguments; the default class name and the Vinyl file object. It must return the new class (string). See Examples for more information. templateAn optional object. See the Custom CSS template examples below. template.fileA string which is a path to a template file (note: this doesn't have to be a .{{className}} {
background: url("{{dataURISchema}}");
} The
Note: template.variablesAn optional object of variable names to variables like this: {
defaultMargin: '.1rem'
} These will be passed to your template along with the template.engineAn optional function which accepts the data (as an object) as its only parameter and returns a string. Consider lodash.template as example. If your favorite templating engine does support a compile + render shorthand, you just need to point the handler after a given template path, otherwise you will need to create a template adapter. template.adapterAn optional function which accepts the template content (string) as its only parameter and returns a template function (or engine). Some templating engines do not have a shorthand to compile + render at the same call. In this specific case we can create a template wrapper as the example below: ExamplesFor example output, see test/expected. Custom CSS templatesThese examples expand on the Combining into one CSS file example but you don't have to concatenate them if you like.
ContributingSee CONTRIBUTING.md Anything missing?Create an issue / pull-request |
2023-10-27
2022-08-15
2022-08-17
2022-09-23
2022-08-13
请发表评论