
Security News
vlt Launches "reproduce": A New Tool Challenging the Limits of Package Provenance
vlt's new "reproduce" tool verifies npm packages against their source code, outperforming traditional provenance adoption in the JavaScript ecosystem.
grunt-data-uri
Advanced tools
This is gruntplugin task.
Convert to data-uri from image path
Install from npm.
% npm i -D grunt-data-uri
Add your project's Gruntfile.js
.
grunt.loadNpmTasks('grunt-data-uri');
grunt.initConfig({
// sample configuration
dataUri: {
dist: {
// src file
src: ['sample/css/raw/*.css'],
// output dir
dest: 'sample/css',
options: {
// specified files are only encoding
target: ['sample/img/embed/*.*'],
// adjust relative path?
fixDirLevel: true,
// img detecting base dir
// baseDir: './'
// Do not inline any images larger
// than this size. 2048 is a size
// recommended by Google's mod_pagespeed.
maxBytes : 2048
}
}
}
}
For traversal image files. If options.baseDir
is specified, use baseDir
instead of src css exsting dir. That's useful when image paths in your css are absolute.
sample/css/raw/main.css
This file is raw css.
html { background-image: url('../../img/embed/will_encode.jpeg'); }
body { background-image: url('../../img/embed/not_encode.jpeg'); }
div { background-image: url('../../img/not_encode.png'); }
Execute grunt-data-uri
% grunt dataUri
Running "dataUri:dist" (dataUri) task
SRC: 3 file uri found on sample/css/raw/main.css
>> Encode: ../../img/embed/will_encode.jpeg
>> Skipping (size 24875 > 10240): ../../img/embed/not_encode.jpeg
>> Adjust: ../../img/not_encode.png -> ../img/not_encode.png
>> => path/to/project/sample/css/main.css
Done, without errors.
sample/css/main.css
This file is processed and output css.
/* encoded to data-uri(base64) */
html { background-image: url('data:image/jpeg;base64,/9j/4AAQSkZJRgABAAAQA...'); }
/* not encoded too large image */
body { background-image: url('../../img/embed/not_encode.jpeg'); }
/* not encoded but adjust relative path! */
div { background-image: url('../img/not_encode.png'); }
npm install
npm test
data-uri
modulemaxBytes
optionfixDirLevel
bugbaseDir
optiondatauri
moduleMIT
FAQs
Convert to data-uri from image path.
The npm package grunt-data-uri receives a total of 187 weekly downloads. As such, grunt-data-uri popularity was classified as not popular.
We found that grunt-data-uri demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Security News
vlt's new "reproduce" tool verifies npm packages against their source code, outperforming traditional provenance adoption in the JavaScript ecosystem.
Research
Security News
Socket researchers uncovered a malicious PyPI package exploiting Deezer’s API to enable coordinated music piracy through API abuse and C2 server control.
Research
The Socket Research Team discovered a malicious npm package, '@ton-wallet/create', stealing cryptocurrency wallet keys from developers and users in the TON ecosystem.