postcss-url
Advanced tools
Comparing version 3.1.0 to 3.2.0
@@ -0,4 +1,8 @@ | ||
# 3.2.0 - 2015-05-01 | ||
- Added: New `fallback` option to use if max size is exceeded or url contains a hash ([#30](https://github.com/postcss/postcss-url/pull/30)) | ||
# 3.1.0 - 2015-05-01 | ||
- Added: New copy value for `url` option | ||
- Added: New copy value for `url` option ([#29](https://github.com/postcss/postcss-url/pull/29)) | ||
@@ -11,3 +15,3 @@ # 3.0.0 - 2015-03-02 | ||
- Fixed: whitespace before and after url() value are now supported and preserved | ||
- Fixed: whitespace before and after url() value are now supported and preserved ([#27](https://github.com/postcss/postcss-url/pull/27)) | ||
@@ -14,0 +18,0 @@ # 2.1.0 - 2015-03-12 |
23
index.js
@@ -110,3 +110,3 @@ /** | ||
case "inline": | ||
return processInline(from, dirname, urlMeta, options) | ||
return processInline(from, dirname, urlMeta, to, options, decl) | ||
case "copy": | ||
@@ -162,7 +162,10 @@ return processCopy(from, dirname, urlMeta, to, options) | ||
* @param {String} urlMeta url meta data | ||
* @param {String} to destination | ||
* @param {Object} options plugin options | ||
* @param {Object} decl postcss declaration | ||
* @return {String} new url | ||
*/ | ||
function processInline(from, dirname, urlMeta, options) { | ||
function processInline(from, dirname, urlMeta, to, options, decl) { | ||
var maxSize = options.maxSize === undefined ? 14 : options.maxSize | ||
var fallback = options.fallback | ||
var basePath = options.basePath | ||
@@ -172,6 +175,18 @@ var fullFilePath | ||
function processFallback() { | ||
if (typeof fallback === "function") { | ||
return processCustom(urlMeta, fallback, decl) | ||
} | ||
switch (fallback) { | ||
case "copy": | ||
return processCopy(from, dirname, urlMeta, to, options) | ||
default: | ||
return createUrl(urlMeta) | ||
} | ||
} | ||
// ignore URLs with hashes/fragments, they can't be inlined | ||
var link = url.parse(urlMeta.value) | ||
if (link.hash) { | ||
return createUrl(urlMeta, urlMeta.value) | ||
return processFallback() | ||
} | ||
@@ -196,3 +211,3 @@ | ||
if (stats.size >= maxSize) { | ||
return createUrl(urlMeta) | ||
return processFallback() | ||
} | ||
@@ -199,0 +214,0 @@ |
{ | ||
"name": "postcss-url", | ||
"version": "3.1.0", | ||
"version": "3.2.0", | ||
"description": "PostCSS plugin to rebase or inline on url().", | ||
@@ -5,0 +5,0 @@ "keywords": [ |
@@ -64,2 +64,6 @@ # postcss-url [![Build Status](https://travis-ci.org/postcss/postcss-url.png)](https://travis-ci.org/postcss/postcss-url) | ||
#### `fallback: "copy or custom {Function}"` | ||
The url fallback method to use if max size is exceeded or url contains a hash. Custom transform functions are supported. | ||
#### `basePath: "basePath for images to inline"` | ||
@@ -66,0 +70,0 @@ |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
15739
263
96