Socket
Socket
Sign inDemoInstall

postcss-base64

Package Overview
Dependencies
Maintainers
1
Versions
15
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

postcss-base64 - npm Package Compare versions

Comparing version 0.3.3 to 0.4.1

test/prepend-expected.css

8

index.js
var fs = require('fs'),
postcss = require('postcss'),
Promise = require('promise');
postcss = require('postcss');

@@ -24,4 +23,5 @@ function getUrl(value) {

function replaceInline(string) {
function replaceInline(string, opts) {
output = new Buffer(string).toString('base64');
if(opts.prepend) output = opts.prepend + output;
return output;

@@ -58,3 +58,3 @@ }

css.replaceValues(search, function (string) {
return replaceInline(string);
return replaceInline(string, opts);
});

@@ -61,0 +61,0 @@ }

{
"name": "postcss-base64",
"version": "0.3.3",
"version": "0.4.1",
"description": "Replace values in url() statements with base64 encoded strings.",

@@ -17,4 +17,3 @@ "author": "Jelmer de Maat",

"fs": "0.0.2",
"postcss": "^5.0.12",
"promise": "^7.0.4"
"postcss": "^5.0.12"
},

@@ -21,0 +20,0 @@ "repository": "git@github.com:jelmerdemaat/postcss-base64.git",

@@ -21,16 +21,21 @@ postcss-base64, a [PostCSS](https://github.com/postcss/postcss/) plugin, replaces urls or values inside `url()` functions with their base64 encoded strings.

`extensions`
#### extensions
An array of extensions of files that have to be encoded, including the leading dot.
_Example: `['.svg']`_
_Example: `extensions: ['.svg']`_
`pattern`
#### pattern
A valid regex pattern to match against the string inside `url()` definitions to encode. Can not match file urls (use `extensions` for this).
_Example: `/<svg.*<\/svg>/i`_
_Example: `pattern: /<svg.*<\/svg>/i`_
#### prepend
String value to prepend before the outputted base64 code. Works only in combination with the pattern approach, for now.
_Example: `prepend: 'data:image/svg+xml;base64,'`_
### NodeJS

@@ -58,3 +63,3 @@ Using PostCSS in NodeJS, the approach would be as follows:

base64({
files: ['.svg']
extensions: ['.svg']
})

@@ -73,3 +78,3 @@ ]))

.selector {
background-image: url('data:image/svg+xml;base64,<svg>...</svg>');
background-image: url('<svg>...</svg>');
}

@@ -80,3 +85,4 @@ ```

var opts = {
pattern: /<svg.*<\/svg>/i
pattern: /<svg.*<\/svg>/i,
prepend: 'data:image/svg+xml;base64,'
}

@@ -83,0 +89,0 @@ ```

Sorry, the diff of this file is not supported yet

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc