Skip to content

Commit e120bed

Browse files
committed
allow data url and external resources
1 parent 015f034 commit e120bed

File tree

3 files changed

+5
-1
lines changed

3 files changed

+5
-1
lines changed

index.js

+1
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,7 @@ module.exports = function(content) {
3333
var uriRegExp = /%CSSURL\[%(.*?)%\]CSSURL%/g;
3434
css = css.replace(uriRegExp, function(str) {
3535
var match = /^%CSSURL\[%(.*?)%\]CSSURL%$/.exec(str);
36+
if(/^data:|^https?:\/\//.test(match[1])) return match[1];
3637
var idx = match[1].indexOf("?");
3738
if(idx < 0) idx = match[1].indexOf("#");
3839
if(idx >= 0) {

package.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "css-loader",
3-
"version": "0.6.3",
3+
"version": "0.6.4",
44
"author": "Tobias Koppers @sokra",
55
"description": "css loader module for webpack",
66
"dependencies": {

test/urlTest.js

+3
Original file line numberDiff line numberDiff line change
@@ -54,6 +54,9 @@ describe("url", function() {
5454
["\".class { background: green url( \"+require(\"./img.png\")+\" ) xyz }\""]);
5555
test("background img 2", ".class { background: green url(~img/png ) url(aaa) xyz }",
5656
["\".class { background: green url(\"+require(\"img/png\")+\" ) url(\"+require(\"./aaa\")+\") xyz }\""]);
57+
test("background img external",
58+
".class { background: green url(data:image/png;base64,AAA) url(http://example.com/image.jpg) xyz }",
59+
["\".class { background: green url(data:image/png;base64,AAA) url(http://example.com/image.jpg) xyz }\""]);
5760
test("font face", "@font-face { src: url(regular.woff) format('woff'), url(~truetype/regular.ttf) format('truetype') }",
5861
["\"@font-face { src: url(\"+require(\"./regular.woff\")+\") format('woff'), url(\"+require(\"truetype/regular.ttf\")+\") format('truetype') }\""]);
5962
testMinimize("minimized simple", ".class { a: b c d; }",

0 commit comments

Comments
 (0)