component-builder
Advanced tools
Comparing version 1.1.12 to 1.1.13
@@ -397,3 +397,3 @@ | ||
var debug = require('debug')('component-builder:scripts'); | ||
var path = require('path'); | ||
var path = pathUtil = require('path'); | ||
var relative = path.relative; | ||
@@ -405,2 +405,3 @@ var requires = require('requires'); | ||
var utils = require('../utils'); | ||
var manifest = require('component-manifest'); | ||
@@ -471,3 +472,3 @@ // default extension to look up | ||
+ '} else if (typeof define == "function" && define.amd) {\n' | ||
+' define("' + canonical + '", [], function(){ return require("' + canonical + '"); });\n' | ||
+' define("' + alias + '", [], function(){ return require("' + canonical + '"); });\n' | ||
+ '} else {\n' | ||
@@ -567,2 +568,4 @@ + ' (this || window)["' + alias + '"] = require("' + canonical + '");\n' | ||
Scripts.prototype.append = wrapGenerator.mark(function(field, file) { | ||
var result; | ||
return wrapGenerator(function($ctx0) { | ||
@@ -590,4 +593,14 @@ while (1) switch ($ctx0.prev = $ctx0.next) { | ||
case 7: | ||
return $ctx0.abrupt("return", this[file.define ? 'define' : 'register'](file) + '\n\n'); | ||
case 8: | ||
if (!file.define) { | ||
$ctx0.next = 11; | ||
break; | ||
} | ||
return $ctx0.abrupt("return", this.define(file) + '\n\n'); | ||
case 11: | ||
return $ctx0.delegateYield(this.register(file), "t1", 12); | ||
case 12: | ||
result = $ctx0.t1; | ||
return $ctx0.abrupt("return", result + '\n\n'); | ||
case 14: | ||
case "end": | ||
@@ -613,47 +626,69 @@ return $ctx0.stop(); | ||
Scripts.prototype.register = function (file) { | ||
var self = this; | ||
var js = file.string; | ||
Scripts.prototype.register = wrapGenerator.mark(function(file) { | ||
var self, js, result, i, require, quote, resolvedPath, resolvedRequire, name; | ||
// rewrite all the requires | ||
js = requires(js, function (require) { | ||
var quote = require.string.match(/"/) ? '"' : "'"; | ||
return 'require(' + quote | ||
+ self.lookup(file, require.path) | ||
+ quote + ')'; | ||
}); | ||
return wrapGenerator(function($ctx1) { | ||
while (1) switch ($ctx1.prev = $ctx1.next) { | ||
case 0: | ||
self = this; | ||
js = file.string; | ||
result = requires(js); | ||
i = 0; | ||
case 4: | ||
if (!(i < result.length)) { | ||
$ctx1.next = 14; | ||
break; | ||
} | ||
// rewrite asset paths | ||
js = assetPaths(js, function (asset) { | ||
asset = relative(file.manifest.path, path.resolve(path.dirname(file.filename), asset)); | ||
return path.join(utils.rewriteUrl(file.branch), asset); | ||
}); | ||
require = result[i]; | ||
quote = require.string.match(/"/) ? '"' : "'"; | ||
return $ctx1.delegateYield(self.lookup(file, require.path), "t2", 8); | ||
case 8: | ||
resolvedPath = $ctx1.t2; | ||
resolvedRequire = 'require(' + quote + resolvedPath + quote + ')'; | ||
js = js.replace(require.string, resolvedRequire); | ||
case 11: | ||
i++; | ||
$ctx1.next = 4; | ||
break; | ||
case 14: | ||
// rewrite asset paths | ||
js = assetPaths(js, function (asset) { | ||
asset = relative(file.manifest.path, path.resolve(path.dirname(file.filename), asset)); | ||
return path.join(utils.rewriteUrl(file.branch), asset); | ||
}); | ||
var name = file.name; | ||
if (this.sourceMap || this.sourceURL) { | ||
if (this.sourceMap && file.sourceMap) { | ||
js += '\n//# sourceMappingURL=' | ||
+ 'data:application/json;charset=utf-8;base64,' | ||
+ new Buffer(file.sourceMap).toString('base64'); | ||
} else { | ||
js += '\n//# sourceURL=' + relative(this.root, file.filename); | ||
name = file.name; | ||
if (this.sourceMap || this.sourceURL) { | ||
if (this.sourceMap && file.sourceMap) { | ||
js += '\n//# sourceMappingURL=' | ||
+ 'data:application/json;charset=utf-8;base64,' | ||
+ new Buffer(file.sourceMap).toString('base64'); | ||
} else { | ||
js += '\n//# sourceURL=' + relative(this.root, file.filename); | ||
} | ||
js = JSON.stringify(js); | ||
js = js.replace(/\\n/g, '\\n\\\n'); | ||
js = 'require.register("' | ||
+ name | ||
+ '", Function("exports, module",\n' | ||
+ js | ||
+ '\n));'; | ||
} else { | ||
js = 'require.register("' | ||
+ name | ||
+ '", function (exports, module) {\n' | ||
+ js | ||
+ '\n});'; | ||
} | ||
return $ctx1.abrupt("return", js); | ||
case 18: | ||
case "end": | ||
return $ctx1.stop(); | ||
} | ||
js = JSON.stringify(js); | ||
js = js.replace(/\\n/g, '\\n\\\n'); | ||
js = 'require.register("' | ||
+ name | ||
+ '", Function("exports, module",\n' | ||
+ js | ||
+ '\n));'; | ||
} else { | ||
js = 'require.register("' | ||
+ name | ||
+ '", function (exports, module) {\n' | ||
+ js | ||
+ '\n});'; | ||
} | ||
}, this); | ||
}); | ||
return js; | ||
} | ||
/** | ||
@@ -742,10 +777,38 @@ * Define a module without the closure. | ||
Scripts.prototype.lookup = function (file, target) { | ||
target = target.toLowerCase(); | ||
Scripts.prototype.lookup = wrapGenerator.mark(function(file, target) { | ||
var currentDir, parentDir, lookup; | ||
return target.slice(0, 2) === './' || target.slice(0, 3) === '../' | ||
? this.lookupRelative(file, target) | ||
: this.lookupDependency(file, target); | ||
} | ||
return wrapGenerator(function($ctx2) { | ||
while (1) switch ($ctx2.prev = $ctx2.next) { | ||
case 0: | ||
target = target.toLowerCase(); | ||
currentDir = target.slice(0, 2) === './'; | ||
parentDir = target.slice(0, 3) === '../'; | ||
if (!(currentDir || parentDir)) { | ||
$ctx2.next = 10; | ||
break; | ||
} | ||
lookup = this.lookupRelative(file, target); | ||
if (!(lookup != null)) { | ||
$ctx2.next = 7; | ||
break; | ||
} | ||
return $ctx2.abrupt("return", lookup); | ||
case 7: | ||
return $ctx2.abrupt("return", target); | ||
case 10: | ||
return $ctx2.delegateYield(this.lookupDependency(file, target), "t3", 11); | ||
case 11: | ||
return $ctx2.abrupt("return", $ctx2.t3); | ||
case 12: | ||
case "end": | ||
return $ctx2.stop(); | ||
} | ||
}, this); | ||
}); | ||
/** | ||
@@ -766,8 +829,10 @@ * Lookup a relative file. | ||
var f = files[i]; | ||
// we need this fallback to check relatives from a foreign local | ||
var name = f.name || pathUtil.join(f.manifest.name, pathUtil.relative(f.manifest.path, f.filename)); | ||
for (var j = 0; j < extensions.length; j++) { | ||
// check by adding extensions | ||
if (f.path.toLowerCase() === path + extensions[j]) return f.name; | ||
if (f.path.toLowerCase() === path + extensions[j]) return name; | ||
} | ||
// check by removing extensions | ||
if (f.path.replace(/\.\w+$/, '').toLowerCase() === path) return f.name; | ||
if (f.path.replace(/\.\w+$/, '').toLowerCase() === path) return name; | ||
} | ||
@@ -777,3 +842,3 @@ | ||
debug(message); | ||
return target; | ||
return null; | ||
} | ||
@@ -800,65 +865,189 @@ | ||
Scripts.prototype.lookupDependency = function (file, target) { | ||
var frags = target.split('/'); | ||
var reference = frags[0]; | ||
var tail = frags.length > 1 | ||
? ('/' + frags.slice(1).join('/')) | ||
: '' | ||
Scripts.prototype.lookupDependency = wrapGenerator.mark(function(file, target) { | ||
var frags, reference, tail, branch, deps, names, name, i, localDeps, re, dep, relativeFile, resolvedTail, repo; | ||
var branch = file.branch; | ||
var deps = branch.dependencies; | ||
var names = Object.keys(deps); | ||
return wrapGenerator(function($ctx3) { | ||
while (1) switch ($ctx3.prev = $ctx3.next) { | ||
case 0: | ||
frags = target.split('/'); | ||
reference = frags[0]; | ||
// <user>~<repo> | ||
if (~reference.indexOf('~')) { | ||
var name = reference.replace('~', '/'); | ||
if (deps[name]) return deps[name].canonical + tail; | ||
} | ||
tail = frags.length > 1 | ||
? ('/' + frags.slice(1).join('/')) | ||
: ''; | ||
// <user>-<repo> | ||
if (~reference.indexOf('-')) { | ||
for (var i = 0; i < names.length; i++) { | ||
var name = names[i]; | ||
if (reference === name.replace('/', '-')) { | ||
return deps[name].canonical + tail; | ||
branch = file.branch; | ||
deps = branch.dependencies; | ||
names = Object.keys(deps); | ||
if (!~reference.indexOf('~')) { | ||
$ctx3.next = 10; | ||
break; | ||
} | ||
} | ||
} | ||
// local | ||
var localDeps = Object.keys(branch.locals); | ||
for (var i = 0; i < localDeps.length; i++) { | ||
// Find a local dependency that matches as a prefix of the target | ||
// or the whole target, and return the canonical path. | ||
var re = new RegExp("^("+localDeps[i]+")(/.*)?$"); | ||
if (m = re.exec(target)) { | ||
var dep = m[1]; | ||
var tail = m[2] || ''; | ||
return branch.locals[dep].canonical + tail; | ||
} | ||
} | ||
name = reference.replace('~', '/'); | ||
// <repo> | ||
for (var i = 0; i < names.length; i++) { | ||
var name = names[i]; | ||
var repo = name.split('/')[1]; | ||
if (repo === reference) { | ||
return deps[name].canonical + tail; | ||
if (!deps[name]) { | ||
$ctx3.next = 10; | ||
break; | ||
} | ||
return $ctx3.abrupt("return", deps[name].canonical + tail); | ||
case 10: | ||
if (!~reference.indexOf('-')) { | ||
$ctx3.next = 19; | ||
break; | ||
} | ||
i = 0; | ||
case 12: | ||
if (!(i < names.length)) { | ||
$ctx3.next = 19; | ||
break; | ||
} | ||
name = names[i]; | ||
if (!(reference === name.replace('/', '-'))) { | ||
$ctx3.next = 16; | ||
break; | ||
} | ||
return $ctx3.abrupt("return", deps[name].canonical + tail); | ||
case 16: | ||
i++; | ||
$ctx3.next = 12; | ||
break; | ||
case 19: | ||
localDeps = Object.keys(branch.locals); | ||
i = 0; | ||
case 21: | ||
if (!(i < localDeps.length)) { | ||
$ctx3.next = 37; | ||
break; | ||
} | ||
re = new RegExp("^("+localDeps[i]+")(/.*)?$"); | ||
if (!(m = re.exec(target))) { | ||
$ctx3.next = 34; | ||
break; | ||
} | ||
dep = m[1]; | ||
tail = m[2] || ''; | ||
if (!(tail !== '')) { | ||
$ctx3.next = 33; | ||
break; | ||
} | ||
relativeFile = '.' + tail; | ||
return $ctx3.delegateYield(this.lookupRelativeForLocal(branch.locals[dep], relativeFile), "t4", 29); | ||
case 29: | ||
resolvedTail = $ctx3.t4; | ||
if (!(resolvedTail != null)) { | ||
$ctx3.next = 33; | ||
break; | ||
} | ||
debug('resolved relative file for local "' + dep + '/' + resolvedTail + '"'); | ||
return $ctx3.abrupt("return", branch.locals[dep].canonical + '/' + resolvedTail); | ||
case 33: | ||
return $ctx3.abrupt("return", branch.locals[dep].canonical + tail); | ||
case 34: | ||
i++; | ||
$ctx3.next = 21; | ||
break; | ||
case 37: | ||
i = 0; | ||
case 38: | ||
if (!(i < names.length)) { | ||
$ctx3.next = 46; | ||
break; | ||
} | ||
name = names[i]; | ||
repo = name.split('/')[1]; | ||
if (!(repo === reference)) { | ||
$ctx3.next = 43; | ||
break; | ||
} | ||
return $ctx3.abrupt("return", deps[name].canonical + tail); | ||
case 43: | ||
i++; | ||
$ctx3.next = 38; | ||
break; | ||
case 46: | ||
i = 0; | ||
case 47: | ||
if (!(i < names.length)) { | ||
$ctx3.next = 55; | ||
break; | ||
} | ||
name = names[i]; | ||
dep = deps[name]; | ||
if (!(dep.node.name.toLowerCase() === reference)) { | ||
$ctx3.next = 52; | ||
break; | ||
} | ||
return $ctx3.abrupt("return", dep.canonical + tail); | ||
case 52: | ||
i++; | ||
$ctx3.next = 47; | ||
break; | ||
case 55: | ||
// to do: look up stuff outside the dependencies | ||
debug('could not resolve "%s" from "%s"', target, file.name); | ||
return $ctx3.abrupt("return", target); | ||
case 57: | ||
case "end": | ||
return $ctx3.stop(); | ||
} | ||
} | ||
}, this); | ||
}); | ||
// component.json name, if different than repo | ||
for (var i = 0; i < names.length; i++) { | ||
var name = names[i]; | ||
var dep = deps[name]; | ||
if (dep.node.name.toLowerCase() === reference) { | ||
return dep.canonical + tail; | ||
Scripts.prototype.lookupRelativeForLocal = wrapGenerator.mark(function(localBranch, relativeTarget) { | ||
var createManifest, manifestGenerator, manifest, obj, resolved, relative; | ||
return wrapGenerator(function($ctx4) { | ||
while (1) switch ($ctx4.prev = $ctx4.next) { | ||
case 0: | ||
createManifest = require('component-manifest'); | ||
manifestGenerator = createManifest(this); | ||
return $ctx4.delegateYield(manifestGenerator(localBranch), "t5", 3); | ||
case 3: | ||
manifest = $ctx4.t5; | ||
obj = { | ||
path: '', // it should simulate a url-relative path | ||
manifest: manifest, | ||
branch: localBranch | ||
}; | ||
resolved = this.lookupRelative(obj, relativeTarget); | ||
if (!(resolved == null)) { | ||
$ctx4.next = 8; | ||
break; | ||
} | ||
return $ctx4.abrupt("return", null); | ||
case 8: | ||
relative = pathUtil.relative(manifest.name, resolved); | ||
return $ctx4.abrupt("return", relative); | ||
case 10: | ||
case "end": | ||
return $ctx4.stop(); | ||
} | ||
} | ||
}, this); | ||
}); | ||
// to do: look up stuff outside the dependencies | ||
debug('could not resolve "%s" from "%s"', target, file.name) | ||
return target | ||
} | ||
// private helpers | ||
@@ -865,0 +1054,0 @@ |
@@ -406,4 +406,2 @@ /** | ||
var resolve = require('url').resolve; | ||
var rewriteCSSURLs = require('css-url-rewriter'); | ||
var utils = require('../utils'); | ||
@@ -431,3 +429,3 @@ | ||
// rewrite URLs | ||
file.string = rewriteCSSURLs(string, function (uri) { | ||
file.string = utils.rewriteCSSURLs(string, function (uri) { | ||
if (isData(uri)) return uri; | ||
@@ -434,0 +432,0 @@ if (isAbsolute(uri)) return uri; |
@@ -512,1 +512,54 @@ (function( | ||
} | ||
/* | ||
* css-url-rewriter | ||
* https://github.com/callumlocke/css-url-rewriter | ||
* | ||
* Copyright (c) 2014 Callum Locke | ||
* Licensed under the MIT license. | ||
*/ | ||
// Regex to find CSS properties that contain URLs | ||
// Fiddle: http://refiddle.com/refiddles/css-url-matcher | ||
// Railroad: http://goo.gl/LXpk52 | ||
var cssPropertyMatcher = /@import[^;]*|[;\s]?\*?[a-zA-Z\-]+\s*\:\#?[^;}]*url\(\s*['"]?[^'"\)\s]+['"]?\s*\)[^;}]*/g; | ||
// Regex to find the URLs within a CSS property value | ||
// Fiddle: http://refiddle.com/refiddles/match-multiple-urls-within-a-css-property-value | ||
// Railroad: http://goo.gl/vQzMcg | ||
var urlMatcher = /url\(\s*['"]?([^)'"]+)['"]?\s*\)/g; | ||
var defaults = { | ||
excludeProperties: ['behavior', '*behavior'] | ||
}; | ||
exports.rewriteCSSURLs = function rewriteCSSURLs(css, settings, rewriterFn) { | ||
// Normalise arguments and settings | ||
if (typeof settings === 'function') { | ||
rewriterFn = settings; | ||
settings = defaults; | ||
} | ||
// Return the modified CSS | ||
var result = css.toString().replace(cssPropertyMatcher, function(property) { | ||
// This function deals with an individual CSS property. | ||
// If this property is excluded, return it unchanged | ||
if (settings.excludeProperties.length) { | ||
var propertyName = property.split(':')[0].replace(/^\s+|\s+$/g, ''); | ||
for (var i = settings.excludeProperties.length - 1; i >= 0; i--) { | ||
if (propertyName.indexOf(settings.excludeProperties[i]) === 0) { | ||
return property; | ||
} | ||
} | ||
} | ||
// Return the property with the URL rewritten | ||
return property.replace(urlMatcher, function(urlFunc, justURL) { | ||
return urlFunc.replace(justURL, rewriterFn(justURL)); | ||
}); | ||
}); | ||
return result; | ||
}; |
var debug = require('debug')('component-builder:scripts'); | ||
var path = require('path'); | ||
var path = pathUtil = require('path'); | ||
var relative = path.relative; | ||
@@ -11,2 +11,3 @@ var requires = require('requires'); | ||
var utils = require('../utils'); | ||
var manifest = require('component-manifest'); | ||
@@ -78,3 +79,3 @@ // default extension to look up | ||
+ '} else if (typeof define == "function" && define.amd) {\n' | ||
+' define("' + canonical + '", [], function(){ return require("' + canonical + '"); });\n' | ||
+' define("' + alias + '", [], function(){ return require("' + canonical + '"); });\n' | ||
+ '} else {\n' | ||
@@ -179,3 +180,8 @@ + ' (this || window)["' + alias + '"] = require("' + canonical + '");\n' | ||
if (typeof file.string !== 'string') return ''; | ||
return this[file.define ? 'define' : 'register'](file) + '\n\n'; | ||
if (file.define) { | ||
return this.define(file) + '\n\n'; | ||
} else { | ||
var result = yield* this.register(file); | ||
return result + '\n\n'; | ||
} | ||
} | ||
@@ -197,3 +203,3 @@ | ||
Scripts.prototype.register = function (file) { | ||
Scripts.prototype.register = function* (file) { | ||
var self = this; | ||
@@ -203,8 +209,11 @@ var js = file.string; | ||
// rewrite all the requires | ||
js = requires(js, function (require) { | ||
var result = requires(js); | ||
for (var i=0; i<result.length; i++) { | ||
var require = result[i]; | ||
var quote = require.string.match(/"/) ? '"' : "'"; | ||
return 'require(' + quote | ||
+ self.lookup(file, require.path) | ||
+ quote + ')'; | ||
}); | ||
var resolvedPath = yield* self.lookup(file, require.path); | ||
var resolvedRequire = 'require(' + quote + resolvedPath + quote + ')'; | ||
js = js.replace(require.string, resolvedRequire); | ||
} | ||
@@ -327,8 +336,14 @@ // rewrite asset paths | ||
Scripts.prototype.lookup = function (file, target) { | ||
Scripts.prototype.lookup = function* (file, target) { | ||
target = target.toLowerCase(); | ||
return target.slice(0, 2) === './' || target.slice(0, 3) === '../' | ||
? this.lookupRelative(file, target) | ||
: this.lookupDependency(file, target); | ||
var currentDir = target.slice(0, 2) === './'; | ||
var parentDir = target.slice(0, 3) === '../'; | ||
if (currentDir || parentDir ) { | ||
var lookup = this.lookupRelative(file, target); | ||
if (lookup != null) return lookup; | ||
return target; | ||
} else { | ||
return yield* this.lookupDependency(file, target); | ||
} | ||
} | ||
@@ -351,8 +366,10 @@ | ||
var f = files[i]; | ||
// we need this fallback to check relatives from a foreign local | ||
var name = f.name || pathUtil.join(f.manifest.name, pathUtil.relative(f.manifest.path, f.filename)); | ||
for (var j = 0; j < extensions.length; j++) { | ||
// check by adding extensions | ||
if (f.path.toLowerCase() === path + extensions[j]) return f.name; | ||
if (f.path.toLowerCase() === path + extensions[j]) return name; | ||
} | ||
// check by removing extensions | ||
if (f.path.replace(/\.\w+$/, '').toLowerCase() === path) return f.name; | ||
if (f.path.replace(/\.\w+$/, '').toLowerCase() === path) return name; | ||
} | ||
@@ -362,3 +379,3 @@ | ||
debug(message); | ||
return target; | ||
return null; | ||
} | ||
@@ -385,3 +402,3 @@ | ||
Scripts.prototype.lookupDependency = function (file, target) { | ||
Scripts.prototype.lookupDependency = function* (file, target) { | ||
var frags = target.split('/'); | ||
@@ -422,3 +439,12 @@ var reference = frags[0]; | ||
var tail = m[2] || ''; | ||
if (tail !== '') { | ||
var relativeFile = '.' + tail; | ||
var resolvedTail = yield* this.lookupRelativeForLocal(branch.locals[dep], relativeFile); | ||
if (resolvedTail != null) { | ||
debug('resolved relative file for local "' + dep + '/' + resolvedTail + '"'); | ||
return branch.locals[dep].canonical + '/' + resolvedTail; | ||
} | ||
} | ||
return branch.locals[dep].canonical + tail; | ||
} | ||
@@ -450,4 +476,23 @@ } | ||
Scripts.prototype.lookupRelativeForLocal = function* (localBranch, relativeTarget) { | ||
var createManifest = require('component-manifest'); | ||
var manifestGenerator = createManifest(this); | ||
var manifest = yield* manifestGenerator(localBranch); | ||
var obj = { | ||
path: '', // it should simulate a url-relative path | ||
manifest: manifest, | ||
branch: localBranch | ||
} | ||
// resolve the file (if extension is not provided) | ||
var resolved = this.lookupRelative(obj, relativeTarget); | ||
if (resolved == null) return null; | ||
var relative = pathUtil.relative(manifest.name, resolved); | ||
return relative; | ||
} | ||
// private helpers | ||
@@ -454,0 +499,0 @@ |
var resolve = require('url').resolve; | ||
var rewriteCSSURLs = require('css-url-rewriter'); | ||
var utils = require('../utils'); | ||
@@ -26,3 +24,3 @@ | ||
// rewrite URLs | ||
file.string = rewriteCSSURLs(string, function (uri) { | ||
file.string = utils.rewriteCSSURLs(string, function (uri) { | ||
if (isData(uri)) return uri; | ||
@@ -29,0 +27,0 @@ if (isAbsolute(uri)) return uri; |
@@ -79,1 +79,55 @@ var fs = require('graceful-fs') | ||
} | ||
/* | ||
* css-url-rewriter | ||
* https://github.com/callumlocke/css-url-rewriter | ||
* | ||
* Copyright (c) 2014 Callum Locke | ||
* Licensed under the MIT license. | ||
*/ | ||
// Regex to find CSS properties that contain URLs | ||
// Fiddle: http://refiddle.com/refiddles/css-url-matcher | ||
// Railroad: http://goo.gl/LXpk52 | ||
var cssPropertyMatcher = /@import[^;]*|[;\s]?\*?[a-zA-Z\-]+\s*\:\#?[^;}]*url\(\s*['"]?[^'"\)\s]+['"]?\s*\)[^;}]*/g; | ||
// Regex to find the URLs within a CSS property value | ||
// Fiddle: http://refiddle.com/refiddles/match-multiple-urls-within-a-css-property-value | ||
// Railroad: http://goo.gl/vQzMcg | ||
var urlMatcher = /url\(\s*['"]?([^)'"]+)['"]?\s*\)/g; | ||
var defaults = { | ||
excludeProperties: ['behavior', '*behavior'] | ||
}; | ||
exports.rewriteCSSURLs = function rewriteCSSURLs(css, settings, rewriterFn) { | ||
// Normalise arguments and settings | ||
if (typeof settings === 'function') { | ||
rewriterFn = settings; | ||
settings = defaults; | ||
} | ||
// Return the modified CSS | ||
var result = css.toString().replace(cssPropertyMatcher, function(property) { | ||
// This function deals with an individual CSS property. | ||
// If this property is excluded, return it unchanged | ||
if (settings.excludeProperties.length) { | ||
var propertyName = property.split(':')[0].replace(/^\s+|\s+$/g, ''); | ||
for (var i = settings.excludeProperties.length - 1; i >= 0; i--) { | ||
if (propertyName.indexOf(settings.excludeProperties[i]) === 0) { | ||
return property; | ||
} | ||
} | ||
} | ||
// Return the property with the URL rewritten | ||
return property.replace(urlMatcher, function(urlFunc, justURL) { | ||
return urlFunc.replace(justURL, rewriterFn(justURL)); | ||
}); | ||
}); | ||
return result; | ||
}; |
{ | ||
"name": "component-builder", | ||
"description": "builder for component", | ||
"version": "1.1.12", | ||
"version": "1.1.13", | ||
"author": { | ||
@@ -20,3 +20,2 @@ "name": "Jonathan Ong", | ||
"cp": "~0.1.1", | ||
"css-url-rewriter": "^0.1.0", | ||
"debug": "*", | ||
@@ -23,0 +22,0 @@ "generator-supported": "~0.0.1", |
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
213199
12
6355
- Removedcss-url-rewriter@^0.1.0
- Removedcss-url-rewriter@0.1.3(transitive)
- Removedextend@3.0.2(transitive)