From 2ee755294d5b57624c8a3eabec0e1e6671912fd9 Mon Sep 17 00:00:00 2001
From: Brian Di Palma <offler@gmail.com>
Date: Fri, 31 Mar 2017 14:23:08 +0100
Subject: [PATCH 01/23] docs(README): improve `getLocalIdent` section (#473)

---
 README.md | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/README.md b/README.md
index 8cc41620..a858091a 100644
--- a/README.md
+++ b/README.md
@@ -205,8 +205,9 @@ You can configure the generated ident with the `localIdentName` query parameter
 }
 ```
 
-You can also specify the absolute path to your custom `getLocalIdent` function to generate classname based on a different schema. Note that this requires `webpack >= v2.x.` since to be able to pass function in. For example:
+You can also specify the absolute path to your custom `getLocalIdent` function to generate classname based on a different schema. This requires `webpack >= 2.2.1` (it supports functions in the `options` object). For example:
 
+**webpack.config.js**
 ```js
 {
   test: /\.css$/,

From 534ea5550ad9096f6559eb3f62263624fc57e1bf Mon Sep 17 00:00:00 2001
From: Evilebot Tnawi <evilebottnawi@users.noreply.github.com>
Date: Tue, 18 Apr 2017 02:47:08 +0300
Subject: [PATCH 02/23] fix: loader now correctly handles `url` with space(s)
 (#495)

---
 lib/processCss.js                      |  5 ++++-
 test/moduleTestCases/urls/expected.css |  2 ++
 test/moduleTestCases/urls/source.css   |  2 ++
 test/urlTest.js                        | 12 ++++++++++++
 4 files changed, 20 insertions(+), 1 deletion(-)

diff --git a/lib/processCss.js b/lib/processCss.js
index 181f7a2a..7f42736f 100644
--- a/lib/processCss.js
+++ b/lib/processCss.js
@@ -98,12 +98,15 @@ var parserPlugin = postcss.plugin("css-loader-parser", function(options) {
 					break;
 				case "url":
 					if (options.url && !/^#/.test(item.url) && loaderUtils.isUrlRequest(item.url, options.root)) {
-						item.stringType = "";
+						if (item.url.indexOf(" ") === -1) {
+							item.stringType = "";
+						}
 						delete item.innerSpacingBefore;
 						delete item.innerSpacingAfter;
 						var url = item.url;
 						item.url = "___CSS_LOADER_URL___" + urlItems.length + "___";
 						urlItems.push({
+							// Add quotes aroung url when contain space
 							url: url
 						});
 					}
diff --git a/test/moduleTestCases/urls/expected.css b/test/moduleTestCases/urls/expected.css
index 50416ce3..ea4dba76 100644
--- a/test/moduleTestCases/urls/expected.css
+++ b/test/moduleTestCases/urls/expected.css
@@ -1,6 +1,8 @@
 ._a_ {
 	background: url({./module});
 	background: url({./module});
+	background: url("{./module module}");
+	background: url('{./module module}');
 	background: url({./module});
 	background: url({./module}#?iefix);
 	background: url("#hash");
diff --git a/test/moduleTestCases/urls/source.css b/test/moduleTestCases/urls/source.css
index beac30e6..1c58afe7 100644
--- a/test/moduleTestCases/urls/source.css
+++ b/test/moduleTestCases/urls/source.css
@@ -1,6 +1,8 @@
 .a {
 	background: url(./module);
 	background: url("./module");
+	background: url("./module module");
+	background: url('./module module');
 	background: url('./module');
 	background: url("./module#?iefix");
 	background: url("#hash");
diff --git a/test/urlTest.js b/test/urlTest.js
index b54bf9a8..29e8d75a 100644
--- a/test/urlTest.js
+++ b/test/urlTest.js
@@ -12,6 +12,12 @@ describe("url", function() {
 	test("background img 3", ".class { background: green url( 'img.png' ) xyz }", [
 		[1, ".class { background: green url({./img.png}) xyz }", ""]
 	]);
+	test("background img contain space in name", ".class { background: green url( \"img img.png\" ) xyz }", [
+		[1, ".class { background: green url(\"{./img img.png}\") xyz }", ""]
+	]);
+	test("background 2 img contain space in name", ".class { background: green url( 'img img.png' ) xyz }", [
+		[1, ".class { background: green url('{./img img.png}') xyz }", ""]
+	]);
 	test("background img absolute", ".class { background: green url(/img.png) xyz }", [
 		[1, ".class { background: green url(/img.png) xyz }", ""]
 	]);
@@ -63,6 +69,12 @@ describe("url", function() {
 	test("background img 3 with url", ".class { background: green url( 'img.png' ) xyz }", [
 		[1, ".class { background: green url( 'img.png' ) xyz }", ""]
 	], "?-url");
+	test("background img with url contain space in name", ".class { background: green url( \"img img.png\" ) xyz }", [
+		[1, ".class { background: green url( \"img img.png\" ) xyz }", ""]
+	], "?-url");
+	test("background 2 img with url contain space in name", ".class { background: green url( 'img img.png' ) xyz }", [
+		[1, ".class { background: green url( 'img img.png' ) xyz }", ""]
+	], "?-url");
 	test("background img absolute with url", ".class { background: green url(/img.png) xyz }", [
 		[1, ".class { background: green url(/img.png) xyz }", ""]
 	], "?-url");

From f99dd75b4c5eefdaf783c2bc14a694ba578337f6 Mon Sep 17 00:00:00 2001
From: Evilebot Tnawi <evilebottnawi@users.noreply.github.com>
Date: Tue, 18 Apr 2017 08:01:41 +0300
Subject: [PATCH 03/23] test: add tests when css contain data uri and source
 maps are enabled (#491)

---
 test/sourceMapTest.js | 34 ++++++++++++++++++++++++++++++++++
 1 file changed, 34 insertions(+)

diff --git a/test/sourceMapTest.js b/test/sourceMapTest.js
index 39401e95..23ac5dc8 100644
--- a/test/sourceMapTest.js
+++ b/test/sourceMapTest.js
@@ -44,6 +44,40 @@ describe("source maps", function() {
 			version: 3
 		}]
 	]);
+	testMap("generate sourceMap (1 loader, data url)", ".class { background-image: url(\"data:image/svg+xml;charset=utf-8,<svg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 42 26' fill='%23007aff'><rect width='4' height='4'/><rect x='8' y='1' width='34' height='2'/><rect y='11' width='4' height='4'/><rect x='8' y='12' width='34' height='2'/><rect y='22' width='4' height='4'/><rect x='8' y='23' width='34' height='2'/></svg>\"); }", undefined, {
+		loaders: [{request: "/path/css-loader"}],
+		options: { context: "/" },
+		resource: "/folder/test.css",
+		request: "/path/css-loader!/folder/test.css",
+		query: "?sourceMap"
+	}, [
+		[1,  ".class { background-image: url(\"data:image/svg+xml;charset=utf-8,<svg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 42 26' fill='%23007aff'><rect width='4' height='4'/><rect x='8' y='1' width='34' height='2'/><rect y='11' width='4' height='4'/><rect x='8' y='12' width='34' height='2'/><rect y='22' width='4' height='4'/><rect x='8' y='23' width='34' height='2'/></svg>\"); }", "", {
+			file: 'test.css',
+			mappings: 'AAAA,SAAS,6WAA6W,EAAE',
+			names: [],
+			sourceRoot: '',
+			sources: [ '/folder/test.css' ],
+			sourcesContent: [ '.class { background-image: url("data:image/svg+xml;charset=utf-8,<svg xmlns=\'http://www.w3.org/2000/svg\' viewBox=\'0 0 42 26\' fill=\'%23007aff\'><rect width=\'4\' height=\'4\'/><rect x=\'8\' y=\'1\' width=\'34\' height=\'2\'/><rect y=\'11\' width=\'4\' height=\'4\'/><rect x=\'8\' y=\'12\' width=\'34\' height=\'2\'/><rect y=\'22\' width=\'4\' height=\'4\'/><rect x=\'8\' y=\'23\' width=\'34\' height=\'2\'/></svg>"); }' ],
+			version: 3
+		}]
+	]);
+	testMap("generate sourceMap (1 loader, encoded data url)", ".class { background-image: url(\"data:image/svg+xml;charset=utf-8,%3Csvg%20xmlns%3D%27http%3A%2F%2Fwww.w3.org%2F2000%2Fsvg%27%20viewBox%3D%270%200%2042%2026%27%20fill%3D%27%23007aff%27%3E%3Crect%20width%3D%274%27%20height%3D%274%27%2F%3E%3Crect%20x%3D%278%27%20y%3D%271%27%20width%3D%2734%27%20height%3D%272%27%2F%3E%3Crect%20y%3D%2711%27%20width%3D%274%27%20height%3D%274%27%2F%3E%3Crect%20x%3D%278%27%20y%3D%2712%27%20width%3D%2734%27%20height%3D%272%27%2F%3E%3Crect%20y%3D%2722%27%20width%3D%274%27%20height%3D%274%27%2F%3E%3Crect%20x%3D%278%27%20y%3D%2723%27%20width%3D%2734%27%20height%3D%272%27%2F%3E%3C%2Fsvg%3E\"); }", undefined, {
+		loaders: [{request: "/path/css-loader"}],
+		options: { context: "/" },
+		resource: "/folder/test.css",
+		request: "/path/css-loader!/folder/test.css",
+		query: "?sourceMap"
+	}, [
+		[1,  ".class { background-image: url(\"data:image/svg+xml;charset=utf-8,%3Csvg%20xmlns%3D%27http%3A%2F%2Fwww.w3.org%2F2000%2Fsvg%27%20viewBox%3D%270%200%2042%2026%27%20fill%3D%27%23007aff%27%3E%3Crect%20width%3D%274%27%20height%3D%274%27%2F%3E%3Crect%20x%3D%278%27%20y%3D%271%27%20width%3D%2734%27%20height%3D%272%27%2F%3E%3Crect%20y%3D%2711%27%20width%3D%274%27%20height%3D%274%27%2F%3E%3Crect%20x%3D%278%27%20y%3D%2712%27%20width%3D%2734%27%20height%3D%272%27%2F%3E%3Crect%20y%3D%2722%27%20width%3D%274%27%20height%3D%274%27%2F%3E%3Crect%20x%3D%278%27%20y%3D%2723%27%20width%3D%2734%27%20height%3D%272%27%2F%3E%3C%2Fsvg%3E\"); }", "", {
+			file: 'test.css',
+			mappings: 'AAAA,SAAS,mmBAAmmB,EAAE',
+			names: [],
+			sourceRoot: '',
+			sources: [ '/folder/test.css' ],
+			sourcesContent: [ '.class { background-image: url("data:image/svg+xml;charset=utf-8,%3Csvg%20xmlns%3D%27http%3A%2F%2Fwww.w3.org%2F2000%2Fsvg%27%20viewBox%3D%270%200%2042%2026%27%20fill%3D%27%23007aff%27%3E%3Crect%20width%3D%274%27%20height%3D%274%27%2F%3E%3Crect%20x%3D%278%27%20y%3D%271%27%20width%3D%2734%27%20height%3D%272%27%2F%3E%3Crect%20y%3D%2711%27%20width%3D%274%27%20height%3D%274%27%2F%3E%3Crect%20x%3D%278%27%20y%3D%2712%27%20width%3D%2734%27%20height%3D%272%27%2F%3E%3Crect%20y%3D%2722%27%20width%3D%274%27%20height%3D%274%27%2F%3E%3Crect%20x%3D%278%27%20y%3D%2723%27%20width%3D%2734%27%20height%3D%272%27%2F%3E%3C%2Fsvg%3E"); }' ],
+			version: 3
+		}]
+	]);
 	testMap("generate sourceMap (2 loaders)", ".class { a: b c d; }", undefined, {
 		loaders: [{request: "/path/css-loader"}, {request: "/path/sass-loader"}],
 		options: { context: "/" },

From bff9c7fc8a730a98a9b3380b4f1053c2e04fda62 Mon Sep 17 00:00:00 2001
From: Evilebot Tnawi <evilebottnawi@users.noreply.github.com>
Date: Tue, 18 Apr 2017 08:07:21 +0300
Subject: [PATCH 04/23] test: add tests for encoded svg data uri (#492)

---
 test/urlTest.js | 16 ++++++++++++++++
 1 file changed, 16 insertions(+)

diff --git a/test/urlTest.js b/test/urlTest.js
index 29e8d75a..9eec659b 100644
--- a/test/urlTest.js
+++ b/test/urlTest.js
@@ -32,10 +32,18 @@ describe("url", function() {
 		".class { background-image: url(\"data:image/svg+xml;charset=utf-8,<svg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 42 26' fill='%23007aff'><rect width='4' height='4'/><rect x='8' y='1' width='34' height='2'/><rect y='11' width='4' height='4'/><rect x='8' y='12' width='34' height='2'/><rect y='22' width='4' height='4'/><rect x='8' y='23' width='34' height='2'/></svg>\") }", [
 		[1, ".class { background-image: url(\"data:image/svg+xml;charset=utf-8,<svg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 42 26' fill='%23007aff'><rect width='4' height='4'/><rect x='8' y='1' width='34' height='2'/><rect y='11' width='4' height='4'/><rect x='8' y='12' width='34' height='2'/><rect y='22' width='4' height='4'/><rect x='8' y='23' width='34' height='2'/></svg>\") }", ""]
 	]);
+	test("background img external encoded data",
+		".class { background-image: url(\"data:image/svg+xml;charset=utf-8,%3Csvg%20xmlns%3D%27http%3A%2F%2Fwww.w3.org%2F2000%2Fsvg%27%20viewBox%3D%270%200%2042%2026%27%20fill%3D%27%2523007aff%27%3E%3Crect%20width%3D%274%27%20height%3D%274%27%2F%3E%3Crect%20x%3D%278%27%20y%3D%271%27%20width%3D%2734%27%20height%3D%272%27%2F%3E%3Crect%20y%3D%2711%27%20width%3D%274%27%20height%3D%274%27%2F%3E%3Crect%20x%3D%278%27%20y%3D%2712%27%20width%3D%2734%27%20height%3D%272%27%2F%3E%3Crect%20y%3D%2722%27%20width%3D%274%27%20height%3D%274%27%2F%3E%3Crect%20x%3D%278%27%20y%3D%2723%27%20width%3D%2734%27%20height%3D%272%27%2F%3E%3C%2Fsvg%3E\") }", [
+			[1, ".class { background-image: url(\"data:image/svg+xml;charset=utf-8,%3Csvg%20xmlns%3D%27http%3A%2F%2Fwww.w3.org%2F2000%2Fsvg%27%20viewBox%3D%270%200%2042%2026%27%20fill%3D%27%2523007aff%27%3E%3Crect%20width%3D%274%27%20height%3D%274%27%2F%3E%3Crect%20x%3D%278%27%20y%3D%271%27%20width%3D%2734%27%20height%3D%272%27%2F%3E%3Crect%20y%3D%2711%27%20width%3D%274%27%20height%3D%274%27%2F%3E%3Crect%20x%3D%278%27%20y%3D%2712%27%20width%3D%2734%27%20height%3D%272%27%2F%3E%3Crect%20y%3D%2722%27%20width%3D%274%27%20height%3D%274%27%2F%3E%3Crect%20x%3D%278%27%20y%3D%2723%27%20width%3D%2734%27%20height%3D%272%27%2F%3E%3C%2Fsvg%3E\") }", ""]
+		]);
 	test("data url in filter",
 		".class { filter: url('data:image/svg+xml;charset=utf-8,<svg xmlns=\"http://www.w3.org/2000/svg\"><filter id=\"filter\"><feGaussianBlur in=\"SourceAlpha\" stdDeviation=\"0\" /><feOffset dx=\"1\" dy=\"2\" result=\"offsetblur\" /><feFlood flood-color=\"rgba(255,255,255,1)\" /><feComposite in2=\"offsetblur\" operator=\"in\" /><feMerge><feMergeNode /><feMergeNode in=\"SourceGraphic\" /></feMerge></filter></svg>#filter'); }", [
 		[1, ".class { filter: url('data:image/svg+xml;charset=utf-8,<svg xmlns=\"http://www.w3.org/2000/svg\"><filter id=\"filter\"><feGaussianBlur in=\"SourceAlpha\" stdDeviation=\"0\" /><feOffset dx=\"1\" dy=\"2\" result=\"offsetblur\" /><feFlood flood-color=\"rgba(255,255,255,1)\" /><feComposite in2=\"offsetblur\" operator=\"in\" /><feMerge><feMergeNode /><feMergeNode in=\"SourceGraphic\" /></feMerge></filter></svg>#filter'); }", ""]
 	]);
+	test("encoded data url in filter",
+		".class { filter: url('data:image/svg+xml;charset=utf-8,%3Csvg%20xmlns%3D%5C%22http%3A%2F%2Fwww.w3.org%2F2000%2Fsvg%5C%22%3E%3Cfilter%20id%3D%5C%22filter%5C%22%3E%3CfeGaussianBlur%20in%3D%5C%22SourceAlpha%5C%22%20stdDeviation%3D%5C%220%5C%22%20%2F%3E%3CfeOffset%20dx%3D%5C%221%5C%22%20dy%3D%5C%222%5C%22%20result%3D%5C%22offsetblur%5C%22%20%2F%3E%3CfeFlood%20flood-color%3D%5C%22rgba(255%2C255%2C255%2C1)%5C%22%20%2F%3E%3CfeComposite%20in2%3D%5C%22offsetblur%5C%22%20operator%3D%5C%22in%5C%22%20%2F%3E%3CfeMerge%3E%3CfeMergeNode%20%2F%3E%3CfeMergeNode%20in%3D%5C%22SourceGraphic%5C%22%20%2F%3E%3C%2FfeMerge%3E%3C%2Ffilter%3E%3C%2Fsvg%3E%23filter'); }", [
+			[1, ".class { filter: url('data:image/svg+xml;charset=utf-8,%3Csvg%20xmlns%3D%5C%22http%3A%2F%2Fwww.w3.org%2F2000%2Fsvg%5C%22%3E%3Cfilter%20id%3D%5C%22filter%5C%22%3E%3CfeGaussianBlur%20in%3D%5C%22SourceAlpha%5C%22%20stdDeviation%3D%5C%220%5C%22%20%2F%3E%3CfeOffset%20dx%3D%5C%221%5C%22%20dy%3D%5C%222%5C%22%20result%3D%5C%22offsetblur%5C%22%20%2F%3E%3CfeFlood%20flood-color%3D%5C%22rgba(255%2C255%2C255%2C1)%5C%22%20%2F%3E%3CfeComposite%20in2%3D%5C%22offsetblur%5C%22%20operator%3D%5C%22in%5C%22%20%2F%3E%3CfeMerge%3E%3CfeMergeNode%20%2F%3E%3CfeMergeNode%20in%3D%5C%22SourceGraphic%5C%22%20%2F%3E%3C%2FfeMerge%3E%3C%2Ffilter%3E%3C%2Fsvg%3E%23filter'); }", ""]
+		]);
 	test("filter hash",
 		".highlight { filter: url(#highlight); }", [
 		[1, ".highlight { filter: url(#highlight); }", ""]
@@ -86,10 +94,18 @@ describe("url", function() {
 		".class { background-image: url(\"data:image/svg+xml;charset=utf-8,<svg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 42 26' fill='%23007aff'><rect width='4' height='4'/><rect x='8' y='1' width='34' height='2'/><rect y='11' width='4' height='4'/><rect x='8' y='12' width='34' height='2'/><rect y='22' width='4' height='4'/><rect x='8' y='23' width='34' height='2'/></svg>\") }", [
 		[1, ".class { background-image: url(\"data:image/svg+xml;charset=utf-8,<svg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 42 26' fill='%23007aff'><rect width='4' height='4'/><rect x='8' y='1' width='34' height='2'/><rect y='11' width='4' height='4'/><rect x='8' y='12' width='34' height='2'/><rect y='22' width='4' height='4'/><rect x='8' y='23' width='34' height='2'/></svg>\") }", ""]
 	], "?-url");
+	test("background img external encoded data with url",
+		".class { background-image: url(\"data:image/svg+xml;charset=utf-8,%3Csvg%20xmlns%3D%27http%3A%2F%2Fwww.w3.org%2F2000%2Fsvg%27%20viewBox%3D%270%200%2042%2026%27%20fill%3D%27%2523007aff%27%3E%3Crect%20width%3D%274%27%20height%3D%274%27%2F%3E%3Crect%20x%3D%278%27%20y%3D%271%27%20width%3D%2734%27%20height%3D%272%27%2F%3E%3Crect%20y%3D%2711%27%20width%3D%274%27%20height%3D%274%27%2F%3E%3Crect%20x%3D%278%27%20y%3D%2712%27%20width%3D%2734%27%20height%3D%272%27%2F%3E%3Crect%20y%3D%2722%27%20width%3D%274%27%20height%3D%274%27%2F%3E%3Crect%20x%3D%278%27%20y%3D%2723%27%20width%3D%2734%27%20height%3D%272%27%2F%3E%3C%2Fsvg%3E\") }", [
+			[1, ".class { background-image: url(\"data:image/svg+xml;charset=utf-8,%3Csvg%20xmlns%3D%27http%3A%2F%2Fwww.w3.org%2F2000%2Fsvg%27%20viewBox%3D%270%200%2042%2026%27%20fill%3D%27%2523007aff%27%3E%3Crect%20width%3D%274%27%20height%3D%274%27%2F%3E%3Crect%20x%3D%278%27%20y%3D%271%27%20width%3D%2734%27%20height%3D%272%27%2F%3E%3Crect%20y%3D%2711%27%20width%3D%274%27%20height%3D%274%27%2F%3E%3Crect%20x%3D%278%27%20y%3D%2712%27%20width%3D%2734%27%20height%3D%272%27%2F%3E%3Crect%20y%3D%2722%27%20width%3D%274%27%20height%3D%274%27%2F%3E%3Crect%20x%3D%278%27%20y%3D%2723%27%20width%3D%2734%27%20height%3D%272%27%2F%3E%3C%2Fsvg%3E\") }", ""]
+		], "?-url");
 	test("data url in filter with url",
 		".class { filter: url('data:image/svg+xml;charset=utf-8,<svg xmlns=\"http://www.w3.org/2000/svg\"><filter id=\"filter\"><feGaussianBlur in=\"SourceAlpha\" stdDeviation=\"0\" /><feOffset dx=\"1\" dy=\"2\" result=\"offsetblur\" /><feFlood flood-color=\"rgba(255,255,255,1)\" /><feComposite in2=\"offsetblur\" operator=\"in\" /><feMerge><feMergeNode /><feMergeNode in=\"SourceGraphic\" /></feMerge></filter></svg>#filter'); }", [
 		[1, ".class { filter: url('data:image/svg+xml;charset=utf-8,<svg xmlns=\"http://www.w3.org/2000/svg\"><filter id=\"filter\"><feGaussianBlur in=\"SourceAlpha\" stdDeviation=\"0\" /><feOffset dx=\"1\" dy=\"2\" result=\"offsetblur\" /><feFlood flood-color=\"rgba(255,255,255,1)\" /><feComposite in2=\"offsetblur\" operator=\"in\" /><feMerge><feMergeNode /><feMergeNode in=\"SourceGraphic\" /></feMerge></filter></svg>#filter'); }", ""]
 	], "?-url");
+	test("encoded data url in filter with url",
+		".class { filter: url('data:image/svg+xml;charset=utf-8,%3Csvg%20xmlns%3D%5C%22http%3A%2F%2Fwww.w3.org%2F2000%2Fsvg%5C%22%3E%3Cfilter%20id%3D%5C%22filter%5C%22%3E%3CfeGaussianBlur%20in%3D%5C%22SourceAlpha%5C%22%20stdDeviation%3D%5C%220%5C%22%20%2F%3E%3CfeOffset%20dx%3D%5C%221%5C%22%20dy%3D%5C%222%5C%22%20result%3D%5C%22offsetblur%5C%22%20%2F%3E%3CfeFlood%20flood-color%3D%5C%22rgba(255%2C255%2C255%2C1)%5C%22%20%2F%3E%3CfeComposite%20in2%3D%5C%22offsetblur%5C%22%20operator%3D%5C%22in%5C%22%20%2F%3E%3CfeMerge%3E%3CfeMergeNode%20%2F%3E%3CfeMergeNode%20in%3D%5C%22SourceGraphic%5C%22%20%2F%3E%3C%2FfeMerge%3E%3C%2Ffilter%3E%3C%2Fsvg%3E%23filter'); }", [
+			[1, ".class { filter: url('data:image/svg+xml;charset=utf-8,%3Csvg%20xmlns%3D%5C%22http%3A%2F%2Fwww.w3.org%2F2000%2Fsvg%5C%22%3E%3Cfilter%20id%3D%5C%22filter%5C%22%3E%3CfeGaussianBlur%20in%3D%5C%22SourceAlpha%5C%22%20stdDeviation%3D%5C%220%5C%22%20%2F%3E%3CfeOffset%20dx%3D%5C%221%5C%22%20dy%3D%5C%222%5C%22%20result%3D%5C%22offsetblur%5C%22%20%2F%3E%3CfeFlood%20flood-color%3D%5C%22rgba(255%2C255%2C255%2C1)%5C%22%20%2F%3E%3CfeComposite%20in2%3D%5C%22offsetblur%5C%22%20operator%3D%5C%22in%5C%22%20%2F%3E%3CfeMerge%3E%3CfeMergeNode%20%2F%3E%3CfeMergeNode%20in%3D%5C%22SourceGraphic%5C%22%20%2F%3E%3C%2FfeMerge%3E%3C%2Ffilter%3E%3C%2Fsvg%3E%23filter'); }", ""]
+		], "?-url");
 	test("filter hash with url",
 		".highlight { filter: url(#highlight); }", [
 		[1, ".highlight { filter: url(#highlight); }", ""]

From 6ee2fc62eb98d0db04b693c07bf957bf67c740a7 Mon Sep 17 00:00:00 2001
From: Evilebot Tnawi <evilebottnawi@users.noreply.github.com>
Date: Tue, 18 Apr 2017 13:14:18 +0300
Subject: [PATCH 05/23] test: add test for escaped characters (#493)

---
 test/simpleTest.js | 33 ++++++++++++++++++++++-----------
 1 file changed, 22 insertions(+), 11 deletions(-)

diff --git a/test/simpleTest.js b/test/simpleTest.js
index 8ff5a662..e05490b0 100644
--- a/test/simpleTest.js
+++ b/test/simpleTest.js
@@ -18,18 +18,29 @@ describe("simple", function() {
 	test("simple2", ".class { a: b c d; }\n.two {}", [
 		[1, ".class { a: b c d; }\n.two {}", ""]
 	]);
+	test("escape characters (uppercase)", ".class { content: \"\\F10C\" }", [
+		[1, ".class { content: \"\\F10C\" }", ""]
+	]);
+	// Need uncomment after resolve https://github.com/css-modules/postcss-modules-local-by-default/issues/108
+	/*test("escape characters (lowercase)", ".class { content: \"\\f10C\" }", [
+		[1, ".class { content: \"\\f10C\" }", ""]
+	]);*/
+	// Need uncomment after resolve https://github.com/mathiasbynens/cssesc/issues/10
+	/*test("escape characters (two)", ".class { content: \"\\F10C \\F10D\" }", [
+		[1, ".class { content: \"\\F10C \\F10D\" }", ""]
+	]);*/
 	testMinimize("minimized simple", ".class { a: b c d; }", [
 		[1, ".class{a:b c d}", ""]
 	]);
-  testError("error formatting", ".some {\n invalid css;\n}", function(err) {
-    assert.equal(err.message, [
-      'Unknown word (2:2)',
-      '',
-      '  1 | .some {',
-      '> 2 |  invalid css;',
-      '    |  ^',
-      '  3 | }',
-      '',
-    ].join('\n'));
-  });
+	testError("error formatting", ".some {\n invalid css;\n}", function(err) {
+		assert.equal(err.message, [
+			'Unknown word (2:2)',
+			'',
+			'  1 | .some {',
+			'> 2 |  invalid css;',
+			'    |  ^',
+			'  3 | }',
+			'',
+		].join('\n'));
+	});
 });

From fbb07146c2ee4b4f55ae8088f2226619ab61ff62 Mon Sep 17 00:00:00 2001
From: Evilebot Tnawi <evilebottnawi@users.noreply.github.com>
Date: Thu, 20 Apr 2017 14:41:11 +0300
Subject: [PATCH 06/23] fix: use `btoa` instead `Buffer` (#501)

---
 lib/css-base.js     |  9 +++++----
 test/cssBaseTest.js | 33 ++++++++++++++++++++++++++++++++-
 2 files changed, 37 insertions(+), 5 deletions(-)

diff --git a/lib/css-base.js b/lib/css-base.js
index b67c1d74..59af87df 100644
--- a/lib/css-base.js
+++ b/lib/css-base.js
@@ -54,7 +54,7 @@ function cssWithMappingToString(item, useSourceMap) {
 		return content;
 	}
 
-	if (useSourceMap) {
+	if (useSourceMap && typeof btoa === 'function') {
 		var sourceMapping = toComment(cssMapping);
 		var sourceURLs = cssMapping.sources.map(function (source) {
 			return '/*# sourceURL=' + cssMapping.sourceRoot + source + ' */'
@@ -68,8 +68,9 @@ function cssWithMappingToString(item, useSourceMap) {
 
 // Adapted from convert-source-map (MIT)
 function toComment(sourceMap) {
-  var base64 = new Buffer(JSON.stringify(sourceMap)).toString('base64');
-  var data = 'sourceMappingURL=data:application/json;charset=utf-8;base64,' + base64;
+	// eslint-disable-next-line no-undef
+	var base64 = btoa(unescape(encodeURIComponent(JSON.stringify(sourceMap))));
+	var data = 'sourceMappingURL=data:application/json;charset=utf-8;base64,' + base64;
 
-  return '/*# ' + data + ' */';
+	return '/*# ' + data + ' */';
 }
diff --git a/test/cssBaseTest.js b/test/cssBaseTest.js
index de176a66..01b2a2ee 100644
--- a/test/cssBaseTest.js
+++ b/test/cssBaseTest.js
@@ -1,8 +1,26 @@
-/*globals describe it*/
+/*eslint-env mocha*/
 
 var base = require("../lib/css-base");
 
 describe("css-base", function() {
+	before(function() {
+		global.btoa = function btoa(str) {
+			var buffer = null;
+
+			if (str instanceof Buffer) {
+				buffer = str;
+			} else {
+				buffer = new Buffer(str.toString(), 'binary');
+			}
+
+			return buffer.toString('base64');
+		}
+	})
+
+	after(function () {
+		global.btoa = null;
+	})
+
 	it("should toString a single module", function() {
 		var m = base();
 		m.push([1, "body { a: 1; }", ""]);
@@ -46,4 +64,17 @@ describe("css-base", function() {
 		}]);
 		m.toString().should.be.eql("body { a: 1; }\n/*# sourceURL=webpack://./path/to/test.scss */\n/*# sourceMappingURL=data:application/json;charset=utf-8;base64,eyJmaWxlIjoidGVzdC5zY3NzIiwic291cmNlcyI6WyIuL3BhdGgvdG8vdGVzdC5zY3NzIl0sIm1hcHBpbmdzIjoiQUFBQTsiLCJzb3VyY2VSb290Ijoid2VicGFjazovLyJ9 */");
 	});
+	it("should toString without source mapping if btoa not avalibale", function() {
+		global.btoa = null;
+		var m = base(true);
+		m.push([1, "body { a: 1; }", "", {
+			file: "test.scss",
+			sources: [
+				'./path/to/test.scss'
+			],
+			mappings: "AAAA;",
+			sourceRoot: "webpack://"
+		}]);
+		m.toString().should.be.eql("body { a: 1; }");
+	});
 });

From e1ec4f27d6ddc7c0c4127ce6704876a5cf705d93 Mon Sep 17 00:00:00 2001
From: Evilebot Tnawi <evilebottnawi@users.noreply.github.com>
Date: Thu, 20 Apr 2017 14:47:28 +0300
Subject: [PATCH 07/23] fix: url with a trailing space is now handled correctly
 (#494)

---
 lib/processCss.js |  2 ++
 test/urlTest.js   | 16 +++++++++++-----
 2 files changed, 13 insertions(+), 5 deletions(-)

diff --git a/lib/processCss.js b/lib/processCss.js
index 7f42736f..7a7edb1d 100644
--- a/lib/processCss.js
+++ b/lib/processCss.js
@@ -156,6 +156,8 @@ module.exports = function processCss(inputSource, inputMap, options, callback) {
 			mode: options.mode,
 			rewriteUrl: function(global, url) {
 				if(parserOptions.url){
+					url = url.trim(" ");
+
 					if(!loaderUtils.isUrlRequest(url, root)) {
 						return url;
 					}
diff --git a/test/urlTest.js b/test/urlTest.js
index 9eec659b..e25a4b77 100644
--- a/test/urlTest.js
+++ b/test/urlTest.js
@@ -12,12 +12,15 @@ describe("url", function() {
 	test("background img 3", ".class { background: green url( 'img.png' ) xyz }", [
 		[1, ".class { background: green url({./img.png}) xyz }", ""]
 	]);
-	test("background img contain space in name", ".class { background: green url( \"img img.png\" ) xyz }", [
-		[1, ".class { background: green url(\"{./img img.png}\") xyz }", ""]
-	]);
-	test("background 2 img contain space in name", ".class { background: green url( 'img img.png' ) xyz }", [
-		[1, ".class { background: green url('{./img img.png}') xyz }", ""]
+	test("background img 4", ".class { background: green url( img.png ) xyz }", [
+		[1, ".class { background: green url({./img.png}) xyz }", ""]
 	]);
+    test("background img contain space in name", ".class { background: green url( \"img img.png\" ) xyz }", [
+        [1, ".class { background: green url(\"{./img img.png}\") xyz }", ""]
+    ]);
+    test("background 2 img contain space in name", ".class { background: green url( 'img img.png' ) xyz }", [
+        [1, ".class { background: green url('{./img img.png}') xyz }", ""]
+    ]);
 	test("background img absolute", ".class { background: green url(/img.png) xyz }", [
 		[1, ".class { background: green url(/img.png) xyz }", ""]
 	]);
@@ -77,6 +80,9 @@ describe("url", function() {
 	test("background img 3 with url", ".class { background: green url( 'img.png' ) xyz }", [
 		[1, ".class { background: green url( 'img.png' ) xyz }", ""]
 	], "?-url");
+	test("background img 4 with url", ".class { background: green url( img.png ) xyz }", [
+		[1, ".class { background: green url( img.png ) xyz }", ""]
+	], "?-url");
 	test("background img with url contain space in name", ".class { background: green url( \"img img.png\" ) xyz }", [
 		[1, ".class { background: green url( \"img img.png\" ) xyz }", ""]
 	], "?-url");

From 5fbf147465cebe106f619cc7088a7222101994ec Mon Sep 17 00:00:00 2001
From: Evilebot Tnawi <evilebottnawi@users.noreply.github.com>
Date: Thu, 20 Apr 2017 17:14:45 +0300
Subject: [PATCH 08/23] test: `charset` directive (#502)

---
 test/simpleTest.js | 3 +++
 1 file changed, 3 insertions(+)

diff --git a/test/simpleTest.js b/test/simpleTest.js
index e05490b0..a8899263 100644
--- a/test/simpleTest.js
+++ b/test/simpleTest.js
@@ -32,6 +32,9 @@ describe("simple", function() {
 	testMinimize("minimized simple", ".class { a: b c d; }", [
 		[1, ".class{a:b c d}", ""]
 	]);
+	test("charset directive", "@charset \"UTF-8\";\n .class { a: b c d; }", [
+		[1, "@charset \"UTF-8\";\n .class { a: b c d; }", ""]
+	]);
 	testError("error formatting", ".some {\n invalid css;\n}", function(err) {
 		assert.equal(err.message, [
 			'Unknown word (2:2)',

From f5f88bb76faaf72fc05c88eafd159099095794b0 Mon Sep 17 00:00:00 2001
From: Michael Ciniawsky <michael.ciniawsky@gmail.com>
Date: Thu, 20 Apr 2017 18:54:57 +0200
Subject: [PATCH 09/23] docs(README): standardize (#503)

---
 README.md | 470 ++++++++++++++++++++++++++++--------------------------
 1 file changed, 247 insertions(+), 223 deletions(-)

diff --git a/README.md b/README.md
index a858091a..3b9e701c 100644
--- a/README.md
+++ b/README.md
@@ -6,7 +6,7 @@
 [![chat][chat]][chat-url]
 
 <div align="center">
-  <img width="200" height="200"
+  <img width="180" height="180" vspace="20"
     src="https://cdn.worldvectorlogo.com/logos/css-3.svg">
   <a href="https://github.com/webpack/webpack">
     <img width="200" height="200"
@@ -23,11 +23,16 @@ npm install --save-dev css-loader
 
 <h2 align="center">Usage</h2>
 
-The `css-loader` interprets `@import` and `url()` like `requires`.
+The `css-loader` interprets `@import` and `url()` like `import/require()`
+and will resolve them.
 
-Use the loader either via your webpack config, CLI or inline.
+Good loaders for requiring your assets are the [file-loader](https://github.com/webpack/file-loader)
+and the [url-loader](https://github.com/webpack/url-loader) which you should specify in your config (see [below](https://github.com/webpack-contrib/css-loader/tree/readme#assets)).
 
-### Via webpack config (recommended)
+**file.css**
+```js
+import css from 'file.css';
+```
 
 **webpack.config.js**
 ```js
@@ -43,109 +48,138 @@ module.exports = {
 }
 ```
 
-**In your application**
-```js
-import css from 'file.css';
-```
-
-### CLI
+### `toString`
 
-```bash
-webpack --module-bind 'css=style-loader!css-loader'
-```
+You can also use the css-loader results directly as string, such as in Angular's component style.
 
-**In your application**
+**webpack.config.js**
 ```js
-import css from 'file.css';
+{
+   test: /\.css$/,
+   use: [
+     'to-string-loader',
+     'css-loader'
+   ]
+}
 ```
 
-### Inline
+or
 
-**In your application**
 ```js
-import css from 'style-loader!css-loader!./file.css';
+const css = require('./test.css').toString();
+
+console.log(css); // {String}
 ```
 
-<h2 align="center">Options</h2>
+If there are SourceMaps, they will also be included in the result string.
 
-`@import` and `url()` are interpreted like `import` and will be resolved by the css-loader.
-Good loaders for requiring your assets are the [file-loader](https://github.com/webpack/file-loader)
-and the [url-loader](https://github.com/webpack/url-loader) which you should specify in your config (see below).
+<h2 align="center">Options</h2>
 
-To be compatible with existing css files (if not in CSS Module mode):
+|Name|Type|Default|Description|
+|:--:|:--:|:-----:|:----------|
+|**`root`**|`{String}`|`/`|Path to resolve URLs, URLs starting with `/` will not be translated|
+|**`url`**|`{Boolean}`|`true`| Enable/Disable `url()` handling|
+|**`alias`**|`{Object}`|`{}`|Create aliases to import certain modules more easily|
+|**`import`** |`{Boolean}`|`true`| Enable/Disable @import handling|
+|**`modules`**|`{Boolean}`|`false`|Enable/Disable CSS Modules|
+|**`minimize`**|`{Boolean\|Object}`|`false`|Enable/Disable minification|
+|**`sourceMap`**|`{Boolean}`|`false`|Enable/Disable Sourcemaps|
+|**`camelCase`**|`{Boolean\|String}`|`false`|Export Classnames in CamelCase|
+|**`importLoaders`**|`{Number}`|`0`|Number of loaders applied before CSS loader|
 
-* `url(image.png)` => `require('./image.png')`
-* `url(~module/image.png)` => `require('module/image.png')`
+### `root`
 
-<h2 align="center">Options</h2>
+For URLs that start with a `/`, the default behavior is to not translate them.
 
-|Name|Default|Description|
-|:--:|:-----:|:----------|
-|**`root`**|`/`|Path to resolve URLs, URLs starting with `/` will not be translated|
-|**`modules`**|`false`|Enable/Disable CSS Modules|
-|**`import`** |`true`| Enable/Disable @import handling|
-|**`url`**|`true`| Enable/Disable `url()` handling|
-|**`minimize`**|`false`|Enable/Disable minification|
-|**`sourceMap`**|`false`|Enable/Disable Sourcemaps|
-|**`camelCase`**|`false`|Export Classnames in CamelCase|
-|**`importLoaders`**|`0`|Number of loaders applied before CSS loader|
-|**`alias`**|`{}`|Create aliases to import certain modules more easily|
+`url(/image.png) => url(/image.png)`
 
-The following webpack config can load CSS files, embed small PNG/JPG/GIF/SVG images as well as fonts as [Data URLs](https://tools.ietf.org/html/rfc2397) and copy larger files to the output directory.
+If a `root` query parameter is set, however, it will be prepended to the URL
+and then translated.
 
 **webpack.config.js**
 ```js
-module.exports = {
-  module: {
-    rules: [
-      {
-        test: /\.css$/,
-        use: [ 'style-loader', 'css-loader' ]
-      },
-      {
-        test: /\.(png|jpg|gif|svg|eot|ttf|woff|woff2)$/,
-        loader: 'url-loader',
-        options: {
-          limit: 10000
-        }
-      }
-    ]
-  }
-};
+{
+  loader: 'css-loader',
+  options: { root: '.' }
+}
+```
+
+`url(/image.png)` => `require('./image.png')`
+
+Using 'Root-relative' urls is not recommended. You should only use it for legacy CSS files.
+
+### `url`
+
+To disable `url()` resolving by `css-loader` set the option to `false`.
+
+To be compatible with existing css files (if not in CSS Module mode).
+
+```
+url(image.png) => require('./image.png')
+url(~module/image.png) => require('module/image.png')
 ```
 
-### Root
+### `alias`
 
-For URLs that start with a `/`, the default behavior is to not translate them:
+Rewrite your urls with alias, this is useful when it's hard to change url paths of your input files, for example, when you're using some css / sass files in another package (bootstrap, ratchet, font-awesome, etc.).
 
-* `url(/image.png)` => `url(/image.png)`
+`css-loader`'s `alias` follows the same syntax as webpack's `resolve.alias`, you can see the details at the [resolve docs] (https://webpack.js.org/configuration/resolve/#resolve-alias)
 
-If a `root` query parameter is set, however, it will be prepended to the URL
-and then translated:
+**file.scss**
+```css
+@charset "UTF-8";
+@import "bootstrap";
+```
 
 **webpack.config.js**
 ```js
-rules: [
-  {
-    test: /\.css$/,
-    use: [
-      'style-loader',
-      {
-        loader: 'css-loader',
-        options: { root: '.' }
+{
+  test: /\.scss$/,
+  use: [
+    {
+      loader: "style-loader"
+    },
+    {
+      loader: "css-loader",
+      options: {
+        alias: {
+          "../fonts/bootstrap": "bootstrap-sass/assets/fonts/bootstrap"
+        }
       }
-    ]
-  }
-]
+    },
+    {
+      loader: "sass-loader",
+      options: {
+        includePaths: [
+          path.resolve("./node_modules/bootstrap-sass/assets/stylesheets")
+        ]
+      }
+    }
+  ]
+}
 ```
 
-* `url(/image.png)` => `require('./image.png')`
+Check out this [working bootstrap example](https://github.com/bbtfr/webpack2-bootstrap-sass-sample).
 
-Using 'Root-relative' urls is not recommended. You should only use it for legacy CSS files.
+### `import`
+
+To disable `@import` resolving by `css-loader` set the option to `false`
+
+```css
+@import @import url('https://fonts.googleapis.com/css?family=Roboto');
+```
 
-### CSS Scope
+> :waning: Use with caution, since this disables resolving for **all** `@import`s
 
-By default CSS exports all class names into a global selector scope. Styles can be locally scoped to avoid globally scoping styles.
+### [`modules`](https://github.com/css-modules/css-modules)
+
+The query parameter `modules` enables the **CSS Modules** spec.
+
+This enables local scoped CSS by default. (You can switch it off with `:global(...)` or `:global` for selectors and/or rules.).
+
+#### `Scope`
+
+By default CSS exports all classnames into a global selector scope. Styles can be locally scoped to avoid globally scoping styles.
 
 The syntax `:local(.className)` can be used to declare `className` in the local scope. The local identifiers are exported by the module.
 
@@ -153,7 +187,6 @@ With `:local` (without brackets) local mode can be switched on for this selector
 
 The loader replaces local selectors with unique identifiers. The choosen unique identifiers are exported by the module.
 
-**app.css**
 ```css
 :local(.className) { background: red; }
 :local .className { color: green; }
@@ -161,17 +194,16 @@ The loader replaces local selectors with unique identifiers. The choosen unique
 :local .className .subClass :global(.global-class-name) { color: blue; }
 ```
 
-**app.bundle.css**
-``` css
+```css
 ._23_aKvs-b8bW2Vg3fwHozO { background: red; }
 ._23_aKvs-b8bW2Vg3fwHozO { color: green; }
 ._23_aKvs-b8bW2Vg3fwHozO ._13LGdX8RMStbBE9w-t0gZ1 { color: green; }
 ._23_aKvs-b8bW2Vg3fwHozO ._13LGdX8RMStbBE9w-t0gZ1 .global-class-name { color: blue; }
 ```
 
-> Note: Identifiers are exported
+> :information_source: Identifiers are exported
 
-``` js
+```js
 exports.locals = {
   className: '_23_aKvs-b8bW2Vg3fwHozO',
   subClass: '_13LGdX8RMStbBE9w-t0gZ1'
@@ -180,13 +212,14 @@ exports.locals = {
 
 CamelCase is recommended for local selectors. They are easier to use in the within the imported JS module.
 
-`url()` URLs in block scoped (`:local .abc`) rules behave like requests in modules:
+`url()` URLs in block scoped (`:local .abc`) rules behave like requests in modules.
 
-* `./file.png` instead of `file.png`
-* `module/file.png` instead of `~module/file.png`
+```
+file.png => ./file.png
+~module/file.png => module/file.png
+```
 
 You can use `:local(#someId)`, but this is not recommended. Use classes instead of ids.
-
 You can configure the generated ident with the `localIdentName` query parameter (default `[hash:base64]`).
 
  **webpack.config.js**
@@ -205,40 +238,29 @@ You can configure the generated ident with the `localIdentName` query parameter
 }
 ```
 
-You can also specify the absolute path to your custom `getLocalIdent` function to generate classname based on a different schema. This requires `webpack >= 2.2.1` (it supports functions in the `options` object). For example:
+You can also specify the absolute path to your custom `getLocalIdent` function to generate classname based on a different schema. This requires `webpack >= 2.2.1` (it supports functions in the `options` object).
 
 **webpack.config.js**
 ```js
 {
-  test: /\.css$/,
-  use: [
-    {
-      loader: 'css-loader',
-      options: {
-        modules: true,
-        localIdentName: '[path][name]__[local]--[hash:base64:5]',
-        getLocalIdent: (context, localIdentName, localName, options) => {
-          return 'whatever_random_class_name'
-        }
-      }
+  loader: 'css-loader',
+  options: {
+    modules: true,
+    localIdentName: '[path][name]__[local]--[hash:base64:5]',
+    getLocalIdent: (context, localIdentName, localName, options) => {
+      return 'whatever_random_class_name'
     }
-  ]
+  }
 }
 ```
 
-Note: For prerendering with extract-text-webpack-plugin you should use `css-loader/locals` instead of `style-loader!css-loader` **in the prerendering bundle**. It doesn't embed CSS but only exports the identifier mappings.
-
-### [CSS Modules](https://github.com/css-modules/css-modules)
+> :information_source: For prerendering with extract-text-webpack-plugin you should use `css-loader/locals` instead of `style-loader!css-loader` **in the prerendering bundle**. It doesn't embed CSS but only exports the identifier mappings.
 
-The query parameter `modules` enables the **CSS Modules** spec.
-
-This enables local scoped CSS by default. (You can switch it off with `:global(...)` or `:global` for selectors and/or rules.)
+#### `Composing`
 
-### CSS Composing
+When declaring a local classname you can compose a local class from another local classname.
 
-When declaring a local class name you can compose a local class from another local class name.
-
-``` css
+```css
 :local(.className) {
   background: red;
   color: yellow;
@@ -250,7 +272,7 @@ When declaring a local class name you can compose a local class from another loc
 }
 ```
 
-This doesn't result in any change to the CSS itself but exports multiple class names:
+This doesn't result in any change to the CSS itself but exports multiple classnames.
 
 ```js
 exports.locals = {
@@ -270,18 +292,18 @@ exports.locals = {
 }
 ```
 
-### Importing CSS Locals
+#### `Importing`
 
-To import a local class name from another module:
+To import a local classname from another module.
 
-``` css
+```css
 :local(.continueButton) {
   composes: button from 'library/button.css';
   background: red;
 }
 ```
 
-``` css
+```css
 :local(.nameEdit) {
   composes: edit highlight from './edit.css';
   background: red;
@@ -290,7 +312,7 @@ To import a local class name from another module:
 
 To import from multiple modules use multiple `composes:` rules.
 
-``` css
+```css
 :local(.className) {
   composes: edit hightlight from './edit.css';
   composes: button from 'module/button.css';
@@ -299,57 +321,74 @@ To import from multiple modules use multiple `composes:` rules.
 }
 ```
 
-### SourceMaps
+### `minimize`
 
-To include Sourcemaps set the `sourceMap` query param.
+By default the css-loader minimizes the css if specified by the module system.
 
-I. e. the extract-text-webpack-plugin can handle them.
+In some cases the minification is destructive to the css, so you can provide your own options to the minifier if needed. cssnano is used for minification and you find a [list of options here](http://cssnano.co/options/).
 
-They are not enabled by default because they expose a runtime overhead and increase in bundle size (JS SourceMap do not). In addition to that relative paths are buggy and you need to use an absolute public path which include the server URL.
+You can also disable or enforce minification with the `minimize` query parameter.
 
 **webpack.config.js**
 ```js
 {
-  test: /\.css$/,
-  use: [
-    {
-      loader: 'css-loader',
-      options: {
-        sourceMap: true
-      }
-    }
-  ]
+  loader: 'css-loader',
+  options: {
+    minimize: true || {/* CSSNano Options */}
+  }
 }
 ```
 
-### toString
+### `sourceMap`
 
-You can also use the css-loader results directly as string, such as in Angular's component style.
+To include source maps set the `sourceMap` option.
 
-**webpack.config.js**
+I. e. the extract-text-webpack-plugin can handle them.
+
+They are not enabled by default because they expose a runtime overhead and increase in bundle size (JS source maps do not). In addition to that relative paths are buggy and you need to use an absolute public path which include the server URL.
 
+**webpack.config.js**
 ```js
 {
-   test: /\.css$/,
-   use: [
-     {
-       loaders: ['to-string-loader', 'css-loader']
-     }
-   ]
+  loader: 'css-loader',
+  options: {
+    sourceMap: true
+  }
 }
 ```
 
-or
+### `camelCase`
 
-```js
-const cssText = require('./test.css').toString();
+By default, the exported JSON keys mirror the class names. If you want to camelize class names (useful in JS), pass the query parameter `camelCase` to css-loader.
+
+|Name|Type|Description|
+|:--:|:--:|:----------|
+|**`true`**|`{Boolean}`|Class names will be camelized|
+|**`'dashes'`**|`{String}`|Only dashes in class names will be camelized|
+|**`'only'`** |`{String}`|Introduced in `0.27.1`. Class names will be camelized, the original class name will be removed from the locals|
+|**`'dashesOnly'`**|`{String}`|Introduced in `0.27.1`. Dashes in class names will be camelized, the original class name will be removed from the locals|
 
-console.log(cssText);
+**file.css**
+```css
+.class-name {}
 ```
 
-If there are SourceMaps, they will also be included in the result string.
+**file.js**
+```js
+import { className } from 'file.css';
+```
+
+**webpack.config.js**
+```js
+{
+  loader: 'css-loader',
+  options: {
+    camelCase: true
+  }
+}
+```
 
-### ImportLoaders
+### `importLoaders`
 
 The query parameter `importLoaders` allow to configure which loaders should be applied to `@import`ed resources.
 
@@ -373,103 +412,68 @@ The query parameter `importLoaders` allow to configure which loaders should be a
 
 This may change in the future, when the module system (i. e. webpack) supports loader matching by origin.
 
-### Minification
+<h2 align="center">Examples</h2>
 
-By default the css-loader minimizes the css if specified by the module system.
-
-In some cases the minification is destructive to the css, so you can provide some options to it. cssnano is used for minification and you find a [list of options here](http://cssnano.co/options/).
+### Assets
 
-You can also disable or enforce minification with the `minimize` query parameter.
+The following `webpack.config.js` can load CSS files, embed small PNG/JPG/GIF/SVG images as well as fonts as [Data URLs](https://tools.ietf.org/html/rfc2397) and copy larger files to the output directory.
 
 **webpack.config.js**
 ```js
-{
-  test: /\.css$/,
-  use: [
-    {
-      loader: 'css-loader',
-      options: {
-        minimize: true || {/* CSSNano Options */}
+module.exports = {
+  module: {
+    rules: [
+      {
+        test: /\.css$/,
+        use: [ 'style-loader', 'css-loader' ]
+      },
+      {
+        test: /\.(png|jpg|gif|svg|eot|ttf|woff|woff2)$/,
+        loader: 'url-loader',
+        options: {
+          limit: 10000
+        }
       }
-    }
-  ]
+    ]
+  }
 }
 ```
 
-### CamelCase
+### Extract
 
-By default, the exported JSON keys mirror the class names. If you want to camelize class names (useful in JS), pass the query parameter `camelCase` to css-loader.
-
-#### Possible Options
-
-|Option|Description|
-|:----:|:--------|
-|**`true`**|Class names will be camelized|
-|**`'dashes'`**|Only dashes in class names will be camelized|
-|**`'only'`** |Introduced in `0.27.1`. Class names will be camelized, the original class name will be removed from the locals|
-|**`'dashesOnly'`**|Introduced in `0.27.1`. Dashes in class names will be camelized, the original class name will be removed from the locals|
+For production builds it's recommended to extract the CSS from your bundle being able to use parallel loading of CSS/JS resources later on. This can be achieved by using the [extract-text-webpack-plugin](https://github.com/webpack-contrib/extract-text-webpack-plugin) to extract the CSS when running in production mode.
 
 **webpack.config.js**
 ```js
-{
-  test: /\.css$/,
-  use: [
-    {
-      loader: 'css-loader',
-      options: {
-        camelCase: true
-      }
-    }
-  ]
-}
-```
-
-```css
-.class-name {}
-```
-
-```js
-import { className } from 'file.css';
-```
+const env = process.env.NODE_ENV
 
-### Alias
+const ExtractTextPlugin = require('extract-text-webpack-plugin')
 
-Rewrite your urls with alias, this is useful when it's hard to change url paths of your input files, for example, when you're using some css / sass files in another package (bootstrap, ratchet, font-awesome, etc.).
-
-#### Possible Options
-
-css-loader's `alias` follows the same syntax as webpack's `resolve.alias`, you can see the details at: https://webpack.js.org/configuration/resolve/#resolve-alias
-
-**webpack.config.js**
-```js
-{
-  test: /\.scss$/,
-  use: [{
-    loader: "style-loader"
-  }, {
-    loader: "css-loader",
-    options: {
-      alias: {
-        "../fonts/bootstrap": "bootstrap-sass/assets/fonts/bootstrap"
-      }
-    }
-  }, {
-    loader: "sass-loader",
-    options: {
-      includePaths: [
-        path.resolve("./node_modules/bootstrap-sass/assets/stylesheets")
+module.exports = {
+  module: {
+    rules: [
+      {
+        test: /\.css$/,
+        use: env === 'production'
+          ? ExtractTextPlugin.extract({
+              fallback: 'style-loader'
+              use: [ 'css-loader' ]
+          })
+          : [ 'style-loader', 'css-loader' ]
+      },
+    ]
+  },
+  plugins: env === 'production'
+    ? [
+        new ExtractTextPlugin({
+          filename: '[name].css'
+        })
       ]
-    }
-  }]
+    : []
+  ]
 }
 ```
 
-```scss
-@charset "UTF-8";
-@import "bootstrap";
-```
-Check out this [working bootstrap example](https://github.com/bbtfr/webpack2-bootstrap-sass-sample).
-
 <h2 align="center">Maintainers</h2>
 
 <table>
@@ -477,29 +481,49 @@ Check out this [working bootstrap example](https://github.com/bbtfr/webpack2-boo
     <tr>
       <td align="center">
         <img width="150" height="150"
-        src="https://avatars3.githubusercontent.com/u/166921?v=3&s=150">
+        src="https://github.com/bebraw.png?v=3&s=150">
         </br>
         <a href="https://github.com/bebraw">Juho Vepsäläinen</a>
       </td>
       <td align="center">
         <img width="150" height="150"
-        src="https://avatars2.githubusercontent.com/u/8420490?v=3&s=150">
+        src="https://github.com/d3viant0ne.png?v=3&s=150">
         </br>
         <a href="https://github.com/d3viant0ne">Joshua Wiens</a>
       </td>
       <td align="center">
         <img width="150" height="150"
-        src="https://avatars3.githubusercontent.com/u/533616?v=3&s=150">
+        src="https://github.com/SpaceK33z.png?v=3&s=150">
         </br>
         <a href="https://github.com/SpaceK33z">Kees Kluskens</a>
       </td>
       <td align="center">
         <img width="150" height="150"
-        src="https://avatars3.githubusercontent.com/u/3408176?v=3&s=150">
+        src="https://github.com/TheLarkInn.png?v=3&s=150">
         </br>
         <a href="https://github.com/TheLarkInn">Sean Larkin</a>
       </td>
     </tr>
+    <tr>
+      <td align="center">
+        <img width="150" height="150"
+        src="https://github.com/michael-ciniawsky.png?v=3&s=150">
+        </br>
+        <a href="https://github.com/michael-ciniawsky">Michael Ciniawsky</a>
+      </td>
+      <td align="center">
+        <img width="150" height="150"
+        src="https://github.com/evilebottnawi.png?v=3&s=150">
+        </br>
+        <a href="https://github.com/evilebottnawi.png">Evilebot Tnawi</a>
+      </td>
+      <td align="center">
+        <img width="150" height="150"
+        src="https://github.com/joscha.png?v=3&s=150">
+        </br>
+        <a href="https://github.com/joscha">Joscha Feth</a>
+      </td>
+    </tr>
   <tbody>
 </table>
 

From 956bad7980fbe8455eafd4c88b52640e4f0983ce Mon Sep 17 00:00:00 2001
From: Evilebot Tnawi <evilebottnawi@users.noreply.github.com>
Date: Thu, 20 Apr 2017 20:09:39 +0300
Subject: [PATCH 10/23] fix: imported variables are replaced in exports if
 followed by a comma (#504)

---
 lib/processCss.js  | 16 +++++++++------
 package.json       |  1 +
 test/valuesTest.js | 51 ++++++++++++++++++++++++++++++++++++++++++++++
 3 files changed, 62 insertions(+), 6 deletions(-)

diff --git a/lib/processCss.js b/lib/processCss.js
index 7a7edb1d..6a3ac1d2 100644
--- a/lib/processCss.js
+++ b/lib/processCss.js
@@ -13,6 +13,7 @@ var localByDefault = require("postcss-modules-local-by-default");
 var extractImports = require("postcss-modules-extract-imports");
 var modulesScope = require("postcss-modules-scope");
 var modulesValues = require("postcss-modules-values");
+var valueParser = require('postcss-value-parser');
 
 var parserPlugin = postcss.plugin("css-loader-parser", function(options) {
 	return function(css) {
@@ -23,15 +24,18 @@ var parserPlugin = postcss.plugin("css-loader-parser", function(options) {
 
 		function replaceImportsInString(str) {
 			if(options.import) {
-				var tokens = str.split(/(\S+)/);
-				tokens = tokens.map(function (token) {
+				var tokens = valueParser(str);
+				tokens.walk(function (node) {
+					if (node.type !== 'word') {
+						return;
+					}
+					var token = node.value;
 					var importIndex = imports["$" + token];
 					if(typeof importIndex === "number") {
-						return "___CSS_LOADER_IMPORT___" + importIndex + "___";
+						node.value = "___CSS_LOADER_IMPORT___" + importIndex + "___";
 					}
-					return token;
-				});
-				return tokens.join("");
+				})
+				return tokens.toString();
 			}
 			return str;
 		}
diff --git a/package.json b/package.json
index 47974860..13ab19c9 100644
--- a/package.json
+++ b/package.json
@@ -23,6 +23,7 @@
     "postcss-modules-local-by-default": "^1.0.1",
     "postcss-modules-scope": "^1.0.0",
     "postcss-modules-values": "^1.1.0",
+    "postcss-value-parser": "^3.3.0",
     "source-list-map": "^0.1.7"
   },
   "devDependencies": {
diff --git a/test/valuesTest.js b/test/valuesTest.js
index 57858407..5b77aa54 100644
--- a/test/valuesTest.js
+++ b/test/valuesTest.js
@@ -66,4 +66,55 @@ describe("values", function() {
 			})()
 		}
 	);
+	testLocal("should import values contain comma",
+		"@value color from './file1'; @value shadow: 0 0 color,0 0 color; .ghi { box-shadow: shadow; }", [
+			[ 2, "", "" ],
+			[ 1, ".ghi { box-shadow: 0 0 red,0 0 red; }", "" ]
+		], {
+			color: "red",
+			shadow: "0 0 red,0 0 red"
+		}, "", {
+			"./file1": (function() {
+				var a =  [[2, "", ""]];
+				a.locals = {
+					color: "red",
+				};
+				return a;
+			})()
+		}
+	);
+	testLocal("should import values contain comma and space before comma",
+		"@value color from './file1'; @value shadow: 0 0 color ,0 0 color; .ghi { box-shadow: shadow; }", [
+			[ 2, "", "" ],
+			[ 1, ".ghi { box-shadow: 0 0 red ,0 0 red; }", "" ]
+		], {
+			color: "red",
+			shadow: "0 0 red ,0 0 red"
+		}, "", {
+			"./file1": (function() {
+				var a =  [[2, "", ""]];
+				a.locals = {
+					color: "red",
+				};
+				return a;
+			})()
+		}
+	);
+	testLocal("should import values contain tralling comma and space after comma",
+		"@value color from './file1'; @value shadow: 0 0 color, 0 0 color; .ghi { box-shadow: shadow; }", [
+			[ 2, "", "" ],
+			[ 1, ".ghi { box-shadow: 0 0 red, 0 0 red; }", "" ]
+		], {
+			color: "red",
+			shadow: "0 0 red, 0 0 red"
+		}, "", {
+			"./file1": (function() {
+				var a =  [[2, "", ""]];
+				a.locals = {
+					color: "red",
+				};
+				return a;
+			})()
+		}
+	);
 });

From 2d4b971a99e3cd91ae78f48afe4fc2916c89a7fc Mon Sep 17 00:00:00 2001
From: Evilebot Tnawi <evilebottnawi@users.noreply.github.com>
Date: Thu, 20 Apr 2017 20:11:57 +0300
Subject: [PATCH 11/23] docs(README): fix typo in maintainers link (#505)

---
 README.md | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/README.md b/README.md
index 3b9e701c..ab234885 100644
--- a/README.md
+++ b/README.md
@@ -515,7 +515,7 @@ module.exports = {
         <img width="150" height="150"
         src="https://github.com/evilebottnawi.png?v=3&s=150">
         </br>
-        <a href="https://github.com/evilebottnawi.png">Evilebot Tnawi</a>
+        <a href="https://github.com/evilebottnawi">Evilebot Tnawi</a>
       </td>
       <td align="center">
         <img width="150" height="150"

From e44735ab228e2573fd60c076104d42d2b8b706bb Mon Sep 17 00:00:00 2001
From: Michael Ciniawsky <michael.ciniawsky@gmail.com>
Date: Fri, 21 Apr 2017 12:12:08 +0200
Subject: [PATCH 12/23] docs(README): fix typo in example (#507)

---
 README.md | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/README.md b/README.md
index ab234885..eeb72754 100644
--- a/README.md
+++ b/README.md
@@ -166,7 +166,7 @@ Check out this [working bootstrap example](https://github.com/bbtfr/webpack2-boo
 To disable `@import` resolving by `css-loader` set the option to `false`
 
 ```css
-@import @import url('https://fonts.googleapis.com/css?family=Roboto');
+@import url('https://fonts.googleapis.com/css?family=Roboto');
 ```
 
 > :waning: Use with caution, since this disables resolving for **all** `@import`s

From 2fa64fdb983a2b1934f5b5cdfff64de1e02f52c5 Mon Sep 17 00:00:00 2001
From: Michael Ciniawsky <michael.ciniawsky@gmail.com>
Date: Fri, 21 Apr 2017 14:23:46 +0200
Subject: [PATCH 13/23] docs(README): fix link (#508)

---
 README.md | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/README.md b/README.md
index eeb72754..081ad18a 100644
--- a/README.md
+++ b/README.md
@@ -27,7 +27,7 @@ The `css-loader` interprets `@import` and `url()` like `import/require()`
 and will resolve them.
 
 Good loaders for requiring your assets are the [file-loader](https://github.com/webpack/file-loader)
-and the [url-loader](https://github.com/webpack/url-loader) which you should specify in your config (see [below](https://github.com/webpack-contrib/css-loader/tree/readme#assets)).
+and the [url-loader](https://github.com/webpack/url-loader) which you should specify in your config (see [below](https://github.com/michael-ciniawsky/css-loader#assets)).
 
 **file.css**
 ```js

From a5fdf841773605e38a5e23858d5f2efc9eb58ddc Mon Sep 17 00:00:00 2001
From: Martin V <ndresx@gmail.com>
Date: Sun, 23 Apr 2017 15:34:06 +0200
Subject: [PATCH 14/23] docs(README): improve importLoaders section and example
 (#512)

---
 README.md | 10 +++++-----
 1 file changed, 5 insertions(+), 5 deletions(-)

diff --git a/README.md b/README.md
index 081ad18a..d19bd58f 100644
--- a/README.md
+++ b/README.md
@@ -390,22 +390,22 @@ import { className } from 'file.css';
 
 ### `importLoaders`
 
-The query parameter `importLoaders` allow to configure which loaders should be applied to `@import`ed resources.
-
-`importLoaders`: That many loaders after the css-loader are used to import resources.
+The query parameter `importLoaders` allows to configure how many loaders before `css-loader` should be applied to `@import`ed resources.
 
 **webpack.config.js**
 ```js
 {
   test: /\.css$/,
   use: [
+    'style-loader',
     {
       loader: 'css-loader',
       options: {
-        importLoaders: 1
+        importLoaders: 1 // 0 => no loaders (default); 1 => postcss-loader; 2 => postcss-loader, sass-loader
       }
     },
-    'postcss-loader'
+    'postcss-loader',
+    'sass-loader'
   ]
 }
 ```

From 67cae9a848c1ac0f120ff16639a24becf89db11a Mon Sep 17 00:00:00 2001
From: Evilebot Tnawi <evilebottnawi@users.noreply.github.com>
Date: Sun, 23 Apr 2017 22:15:34 +0300
Subject: [PATCH 15/23] chore: update comment (#515)

---
 lib/processCss.js | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/lib/processCss.js b/lib/processCss.js
index 6a3ac1d2..fb2ad703 100644
--- a/lib/processCss.js
+++ b/lib/processCss.js
@@ -102,6 +102,7 @@ var parserPlugin = postcss.plugin("css-loader-parser", function(options) {
 					break;
 				case "url":
 					if (options.url && !/^#/.test(item.url) && loaderUtils.isUrlRequest(item.url, options.root)) {
+						// Don't remove quotes around url when contain space
 						if (item.url.indexOf(" ") === -1) {
 							item.stringType = "";
 						}
@@ -110,7 +111,6 @@ var parserPlugin = postcss.plugin("css-loader-parser", function(options) {
 						var url = item.url;
 						item.url = "___CSS_LOADER_URL___" + urlItems.length + "___";
 						urlItems.push({
-							// Add quotes aroung url when contain space
 							url: url
 						});
 					}

From de4356b6c869553c843f48e032432b4f8dfacb71 Mon Sep 17 00:00:00 2001
From: Evilebot Tnawi <evilebottnawi@users.noreply.github.com>
Date: Sun, 23 Apr 2017 22:30:32 +0300
Subject: [PATCH 16/23] fix: case insensitivity of @import (#514)

---
 lib/processCss.js  | 2 +-
 test/importTest.js | 6 ++++++
 2 files changed, 7 insertions(+), 1 deletion(-)

diff --git a/lib/processCss.js b/lib/processCss.js
index fb2ad703..2c2fea6d 100644
--- a/lib/processCss.js
+++ b/lib/processCss.js
@@ -41,7 +41,7 @@ var parserPlugin = postcss.plugin("css-loader-parser", function(options) {
 		}
 
 		if(options.import) {
-			css.walkAtRules("import", function(rule) {
+			css.walkAtRules(/import/i, function(rule) {
 				var values = Tokenizer.parseValues(rule.params);
 				var url = values.nodes[0].nodes[0];
 				if(url.type === "url") {
diff --git a/test/importTest.js b/test/importTest.js
index 19efac8b..52c94510 100644
--- a/test/importTest.js
+++ b/test/importTest.js
@@ -9,6 +9,12 @@ describe("import", function() {
 	], "", {
 		"./test.css": [[2, ".test{a: b}", ""]]
 	});
+	test("import camelcase", "@IMPORT url(test.css);\n.class { a: b c d; }", [
+		[2, ".test{a: b}", ""],
+		[1, ".class { a: b c d; }", ""]
+	], "", {
+		"./test.css": [[2, ".test{a: b}", ""]]
+	});
 	test("import with string", "@import \"test.css\";\n.class { a: b c d; }", [
 		[2, ".test{a: b}", ""],
 		[1, ".class { a: b c d; }", ""]

From c1973436f43a2e61462fe7b331a395e9afa16518 Mon Sep 17 00:00:00 2001
From: Erwann Mest <m+github@kud.io>
Date: Tue, 25 Apr 2017 20:32:56 +0200
Subject: [PATCH 17/23] docs(README): add note about compose when imports are
 disabled (#517)

---
 README.md | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/README.md b/README.md
index d19bd58f..05858e5e 100644
--- a/README.md
+++ b/README.md
@@ -169,7 +169,7 @@ To disable `@import` resolving by `css-loader` set the option to `false`
 @import url('https://fonts.googleapis.com/css?family=Roboto');
 ```
 
-> :waning: Use with caution, since this disables resolving for **all** `@import`s
+> :waning: Use with caution, since this disables resolving for **all** `@import`s, including css modules `composes: xxx from 'path/to/file.css'` feature.
 
 ### [`modules`](https://github.com/css-modules/css-modules)
 

From b90d8dde0add56703dda2252bd7352acbb3100a2 Mon Sep 17 00:00:00 2001
From: Erwann Mest <m+github@kud.io>
Date: Wed, 26 Apr 2017 01:31:49 +0200
Subject: [PATCH 18/23] docs(README): fix warning note about import (#519)

---
 README.md | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/README.md b/README.md
index 05858e5e..43e5ee0e 100644
--- a/README.md
+++ b/README.md
@@ -169,7 +169,7 @@ To disable `@import` resolving by `css-loader` set the option to `false`
 @import url('https://fonts.googleapis.com/css?family=Roboto');
 ```
 
-> :waning: Use with caution, since this disables resolving for **all** `@import`s, including css modules `composes: xxx from 'path/to/file.css'` feature.
+> _⚠️ Use with caution, since this disables resolving for **all** `@import`s, including css modules `composes: xxx from 'path/to/file.css'` feature._
 
 ### [`modules`](https://github.com/css-modules/css-modules)
 

From 760eefa9a5b112f69fd2f5fe337a4d08b1a0a769 Mon Sep 17 00:00:00 2001
From: Marek Suscak <marek.suscak@gmail.com>
Date: Wed, 26 Apr 2017 21:18:51 +0200
Subject: [PATCH 19/23] docs(README): add extract-loader example (#518)

---
 README.md | 17 +++++++++++++++++
 1 file changed, 17 insertions(+)

diff --git a/README.md b/README.md
index 43e5ee0e..6033723a 100644
--- a/README.md
+++ b/README.md
@@ -73,6 +73,23 @@ console.log(css); // {String}
 
 If there are SourceMaps, they will also be included in the result string.
 
+If, for one reason or another, you need to extract CSS as a
+plain string resource (i.e. not wrapped in a JS module) you
+might want to check out the [extract-loader](https://github.com/peerigon/extract-loader).
+It's useful when you, for instance, need to post process the CSS as a string.
+
+**webpack.config.js**
+```js
+{
+   test: /\.css$/,
+   use: [
+     'handlebars-loader', // handlebars loader expects raw resource string
+     'extract-loader',
+     'css-loader'
+   ]
+}
+```
+
 <h2 align="center">Options</h2>
 
 |Name|Type|Default|Description|

From b8f5c8fc3fa146df01a9dca65c475c33cc679bd5 Mon Sep 17 00:00:00 2001
From: Evilebot Tnawi <evilebottnawi@users.noreply.github.com>
Date: Wed, 26 Apr 2017 22:27:59 +0300
Subject: [PATCH 20/23] perf: generate source maps only when explicitly set
 (#478)

---
 lib/loader.js         | 13 ++++++++++---
 lib/processCss.js     |  4 ++--
 test/sourceMapTest.js | 27 +++++++++++++++++++++++++++
 3 files changed, 39 insertions(+), 5 deletions(-)

diff --git a/lib/loader.js b/lib/loader.js
index b55b35f9..ea4d8372 100644
--- a/lib/loader.js
+++ b/lib/loader.js
@@ -16,10 +16,16 @@ module.exports = function(content, map) {
 	var root = query.root;
 	var moduleMode = query.modules || query.module;
 	var camelCaseKeys = query.camelCase || query.camelcase;
+	var sourceMap = query.sourceMap || false;
 	var resolve = createResolver(query.alias);
 
-	if(map !== null && typeof map !== "string") {
-		map = JSON.stringify(map);
+	if(sourceMap) {
+		if (map && typeof map !== "string") {
+			map = JSON.stringify(map);
+		}
+	} else {
+		// Some loaders (example `"postcss-loader": "1.x.x"`) always generates source map, we should remove it
+		map = null;
 	}
 
 	processCss(content, map, {
@@ -28,7 +34,8 @@ module.exports = function(content, map) {
 		to: loaderUtils.getCurrentRequest(this),
 		query: query,
 		minimize: this.minimize,
-		loaderContext: this
+		loaderContext: this,
+		sourceMap: sourceMap
 	}, function(err, result) {
 		if(err) return callback(err);
 
diff --git a/lib/processCss.js b/lib/processCss.js
index 2c2fea6d..34017d5e 100644
--- a/lib/processCss.js
+++ b/lib/processCss.js
@@ -200,12 +200,12 @@ module.exports = function processCss(inputSource, inputMap, options, callback) {
 		// we need a prefix to avoid path rewriting of PostCSS
 		from: "/css-loader!" + options.from,
 		to: options.to,
-		map: {
+		map: options.sourceMap ? {
 			prev: inputMap,
 			sourcesContent: true,
 			inline: false,
 			annotation: false
-		}
+		} : null
 	}).then(function(result) {
 		callback(null, {
 			source: result.css,
diff --git a/test/sourceMapTest.js b/test/sourceMapTest.js
index 23ac5dc8..3bb84f66 100644
--- a/test/sourceMapTest.js
+++ b/test/sourceMapTest.js
@@ -10,6 +10,24 @@ describe("source maps", function() {
 	testWithMap("falsy: undefined map doesn't cause an error", ".class { a: b c d; }", undefined, [
 		[1, ".class { a: b c d; }", ""]
 	]);
+    testWithMap("should don't generate sourceMap when `sourceMap: false` and map exist",
+		".class { a: b c d; }",
+        {
+            file: 'test.css',
+            mappings: 'AAAA,SAAS,SAAS,EAAE',
+            names: [],
+            sourceRoot: '',
+            sources: [ '/folder/test.css' ],
+            sourcesContent: [ '.class { a: b c d; }' ],
+            version: 3
+        },
+		[
+			[1, ".class { a: b c d; }", ""]
+		],
+		{
+            query: "?sourceMap=false"
+		}
+	);
 	testMap("generate sourceMap (1 loader)", ".class { a: b c d; }", undefined, {
 		loaders: [{request: "/path/css-loader"}],
 		options: { context: "/" },
@@ -95,4 +113,13 @@ describe("source maps", function() {
 			version: 3
 		}]
 	]);
+	testMap("don't generate sourceMap (1 loader)", ".class { a: b c d; }", undefined, {
+		loaders: [{request: "/path/css-loader"}],
+		options: { context: "/" },
+		resource: "/folder/test.css",
+		request: "/path/css-loader!/folder/test.css",
+		query: "?sourceMap=false"
+	}, [
+		[1, ".class { a: b c d; }", ""]
+	]);
 });

From 06d27a15652ecc15a6ea1029a1e142ab2f9bcfe0 Mon Sep 17 00:00:00 2001
From: Evilebot Tnawi <evilebottnawi@users.noreply.github.com>
Date: Wed, 26 Apr 2017 22:32:18 +0300
Subject: [PATCH 21/23] fix: allow to specify a full hostname as a root URL
 (#521)

---
 lib/processCss.js | 2 +-
 test/urlTest.js   | 9 +++++++++
 2 files changed, 10 insertions(+), 1 deletion(-)

diff --git a/lib/processCss.js b/lib/processCss.js
index 34017d5e..6dcb909a 100644
--- a/lib/processCss.js
+++ b/lib/processCss.js
@@ -139,7 +139,7 @@ var parserPlugin = postcss.plugin("css-loader-parser", function(options) {
 
 module.exports = function processCss(inputSource, inputMap, options, callback) {
 	var query = options.query;
-	var root = query.root;
+	var root = query.root && query.root.length > 0 ? query.root.replace(/\/$/, "") : query.root;
 	var context = query.context;
 	var localIdentName = query.localIdentName || "[hash:base64]";
 	var localIdentRegExp = query.localIdentRegExp;
diff --git a/test/urlTest.js b/test/urlTest.js
index e25a4b77..5f5b7f52 100644
--- a/test/urlTest.js
+++ b/test/urlTest.js
@@ -27,6 +27,15 @@ describe("url", function() {
 	test("background img absolute with root", ".class { background: green url(/img.png) xyz }", [
 		[1, ".class { background: green url({./img.png}) xyz }", ""]
 	], "?root=.");
+	test("background img absolute with root", ".class { background: green url(/img.png) xyz }", [
+		[1, ".class { background: green url({./img.png}) xyz }", ""]
+	], "?root=./");
+	test("root with absolute url", ".class { background: green url(/img.png) xyz }", [
+		[1, ".class { background: green url(http://some.cdn.com/img.png) xyz }", ""]
+	], "?root=http://some.cdn.com");
+	test("root with absolute url with trailing slash", ".class { background: green url(/img.png) xyz }", [
+		[1, ".class { background: green url(http://some.cdn.com/img.png) xyz }", ""]
+	], "?root=http://some.cdn.com/");
 	test("background img external",
 		".class { background: green url(data:image/png;base64,AAA) url(http://example.com/image.jpg) url(//example.com/image.png) xyz }", [
 		[1, ".class { background: green url(data:image/png;base64,AAA) url(http://example.com/image.jpg) url(//example.com/image.png) xyz }", ""]

From 868fc946eac43ce5b670a9ca9ae97ebe13d9f022 Mon Sep 17 00:00:00 2001
From: Evilebot Tnawi <evilebottnawi@users.noreply.github.com>
Date: Wed, 26 Apr 2017 22:54:58 +0300
Subject: [PATCH 22/23] fix: don't handle empty @import and url() (#513)

---
 lib/processCss.js  |  9 ++++---
 test/importTest.js | 21 ++++++++++++++++
 test/urlTest.js    | 60 +++++++++++++++++++++++++++++++++++++++++-----
 3 files changed, 81 insertions(+), 9 deletions(-)

diff --git a/lib/processCss.js b/lib/processCss.js
index 6dcb909a..585d37d0 100644
--- a/lib/processCss.js
+++ b/lib/processCss.js
@@ -49,6 +49,9 @@ var parserPlugin = postcss.plugin("css-loader-parser", function(options) {
 				} else if(url.type === "string") {
 					url = url.value;
 				} else throw rule.error("Unexpected format" + rule.params);
+				if (!url.replace(/\s/g, '').length) {
+					return;
+				}
 				values.nodes[0].nodes.shift();
 				var mediaQuery = Tokenizer.stringifyValues(values);
 				if(loaderUtils.isUrlRequest(url, options.root) && options.mode === "global") {
@@ -101,7 +104,7 @@ var parserPlugin = postcss.plugin("css-loader-parser", function(options) {
 					}
 					break;
 				case "url":
-					if (options.url && !/^#/.test(item.url) && loaderUtils.isUrlRequest(item.url, options.root)) {
+					if (options.url && item.url.replace(/\s/g, '').length && !/^#/.test(item.url) && loaderUtils.isUrlRequest(item.url, options.root)) {
 						// Don't remove quotes around url when contain space
 						if (item.url.indexOf(" ") === -1) {
 							item.stringType = "";
@@ -160,9 +163,9 @@ module.exports = function processCss(inputSource, inputMap, options, callback) {
 			mode: options.mode,
 			rewriteUrl: function(global, url) {
 				if(parserOptions.url){
-					url = url.trim(" ");
+                    url = url.trim();
 
-					if(!loaderUtils.isUrlRequest(url, root)) {
+					if(!url.replace(/\s/g, '').length || !loaderUtils.isUrlRequest(url, root)) {
 						return url;
 					}
 					if(global) {
diff --git a/test/importTest.js b/test/importTest.js
index 52c94510..f52425fa 100644
--- a/test/importTest.js
+++ b/test/importTest.js
@@ -15,12 +15,33 @@ describe("import", function() {
 	], "", {
 		"./test.css": [[2, ".test{a: b}", ""]]
 	});
+    test("import empty url", "@import url();\n.class { a: b c d; }", [
+        [1, "@import url();\n.class { a: b c d; }", ""]
+    ], "");
+    test("import empty url with quotes", "@import url('');\n.class { a: b c d; }", [
+        [1, "@import url('');\n.class { a: b c d; }", ""]
+    ], "");
 	test("import with string", "@import \"test.css\";\n.class { a: b c d; }", [
 		[2, ".test{a: b}", ""],
 		[1, ".class { a: b c d; }", ""]
 	], "", {
 		"./test.css": [[2, ".test{a: b}", ""]]
 	});
+	test("import with empty string", "@import \"\";\n.class { a: b c d; }", [
+		[1, "@import \"\";\n.class { a: b c d; }", ""]
+	], "");
+	test("import with string contain spaces", "@import \"   \";\n.class { a: b c d; }", [
+		[1, "@import \"   \";\n.class { a: b c d; }", ""]
+	], "");
+	test("import with string contain newline", "@import \"\n\";\n.class { a: b c d; }", [
+		[1, "@import \"\n\";\n.class { a: b c d; }", ""]
+	], "");
+	test("import with string contain CRLF", "@import \"\r\n\";\r\n.class { a: b c d; }", [
+		[1, "@import \"\r\n\";\r\n.class { a: b c d; }", ""]
+	], "");
+	test("import with string contain tab", "@import \"\t\";\n.class { a: b c d; }", [
+		[1, "@import \"\t\";\n.class { a: b c d; }", ""]
+	], "");
 	test("import 2", "@import url('test.css');\n.class { a: b c d; }", [
 		[2, ".test{a: b}", "screen"],
 		[1, ".class { a: b c d; }", ""]
diff --git a/test/urlTest.js b/test/urlTest.js
index 5f5b7f52..bfe5c4ee 100644
--- a/test/urlTest.js
+++ b/test/urlTest.js
@@ -15,12 +15,12 @@ describe("url", function() {
 	test("background img 4", ".class { background: green url( img.png ) xyz }", [
 		[1, ".class { background: green url({./img.png}) xyz }", ""]
 	]);
-    test("background img contain space in name", ".class { background: green url( \"img img.png\" ) xyz }", [
-        [1, ".class { background: green url(\"{./img img.png}\") xyz }", ""]
-    ]);
-    test("background 2 img contain space in name", ".class { background: green url( 'img img.png' ) xyz }", [
-        [1, ".class { background: green url('{./img img.png}') xyz }", ""]
-    ]);
+	test("background img contain space in name", ".class { background: green url( \"img img.png\" ) xyz }", [
+		[1, ".class { background: green url(\"{./img img.png}\") xyz }", ""]
+	]);
+	test("background 2 img contain space in name", ".class { background: green url( 'img img.png' ) xyz }", [
+		[1, ".class { background: green url('{./img img.png}') xyz }", ""]
+	]);
 	test("background img absolute", ".class { background: green url(/img.png) xyz }", [
 		[1, ".class { background: green url(/img.png) xyz }", ""]
 	]);
@@ -79,6 +79,30 @@ describe("url", function() {
 	test("-webkit-image-set", ".a { background-image: -webkit-image-set(url('url1x.png') 1x, url('url2x.png') 2x) }", [
 		[1, ".a { background-image: -webkit-image-set(url({./url1x.png}) 1x, url({./url2x.png}) 2x) }", ""]
 	]);
+	test("empty url", ".class { background: green url() xyz }", [
+		[1, ".class { background: green url() xyz }", ""]
+	]);
+	test("empty url with quotes", ".class { background: green url('') xyz }", [
+		[1, ".class { background: green url('') xyz }", ""]
+	]);
+	test("empty url with spaces and quotes", ".class { background: green url('   ') xyz }", [
+		[1, ".class { background: green url('') xyz }", ""]
+	]);
+	test("empty url with newline and quotes", ".class { background: green url('\n') xyz }", [
+		[1, ".class { background: green url('') xyz }", ""]
+	]);
+	test("empty url with CRLF and quotes", ".class { background: green url('\r\n') xyz }", [
+		[1, ".class { background: green url('') xyz }", ""]
+	]);
+	test("empty url with tab and quotes", ".class { background: green url('\t') xyz }", [
+		[1, ".class { background: green url('') xyz }", ""]
+	]);
+	test("external absolute url", ".class { background: green url(https://raw.githubusercontent.com/webpack/media/master/logo/icon.png) xyz }", [
+		[1, ".class { background: green url(https://raw.githubusercontent.com/webpack/media/master/logo/icon.png) xyz }", ""]
+	]);
+	test("external schema-less url", ".class { background: green url(//raw.githubusercontent.com/webpack/media/master/logo/icon.png) xyz }", [
+		[1, ".class { background: green url(//raw.githubusercontent.com/webpack/media/master/logo/icon.png) xyz }", ""]
+	]);
 
 	test("background img with url", ".class { background: green url( \"img.png\" ) xyz }", [
 		[1, ".class { background: green url( \"img.png\" ) xyz }", ""]
@@ -141,4 +165,28 @@ describe("url", function() {
 	test("keyframe background img with url", "@keyframes anim { background: green url('img.png') xyz }", [
 		[1, "@keyframes anim { background: green url('img.png') xyz }", ""]
 	], "?-url");
+	test("empty url", ".class { background: green url() xyz }", [
+		[1, ".class { background: green url() xyz }", ""]
+	], "?-url");
+	test("empty url with quotes", ".class { background: green url('') xyz }", [
+		[1, ".class { background: green url('') xyz }", ""]
+	], "?-url");
+	test("empty url with spaces and quotes", ".class { background: green url('   ') xyz }", [
+		[1, ".class { background: green url('   ') xyz }", ""]
+	], "?-url");
+	test("empty url with newline and quotes", ".class { background: green url('\n') xyz }", [
+		[1, ".class { background: green url('\n') xyz }", ""]
+	], "?-url");
+	test("empty url with CRLF and quotes", ".class { background: green url('\r\n') xyz }", [
+		[1, ".class { background: green url('\r\n') xyz }", ""]
+	], "?-url");
+	test("empty url with tab and quotes", ".class { background: green url('\t') xyz }", [
+		[1, ".class { background: green url('\t') xyz }", ""]
+	], "?-url");
+	test("external absolute url", ".class { background: green url(https://raw.githubusercontent.com/webpack/media/master/logo/icon.png) xyz }", [
+		[1, ".class { background: green url(https://raw.githubusercontent.com/webpack/media/master/logo/icon.png) xyz }", ""]
+	], "?-url");
+	test("external schema-less url", ".class { background: green url(//raw.githubusercontent.com/webpack/media/master/logo/icon.png) xyz }", [
+		[1, ".class { background: green url(//raw.githubusercontent.com/webpack/media/master/logo/icon.png) xyz }", ""]
+	], "?-url");
 });

From ae67b2a9eab5b4e27146ac73aff8854b227a081a Mon Sep 17 00:00:00 2001
From: Joshua Wiens <joshuaw@easymetrics.com>
Date: Tue, 2 May 2017 02:17:41 -0500
Subject: [PATCH 23/23] chore(release): 0.28.1

---
 CHANGELOG.md | 21 +++++++++++++++++++++
 package.json |  2 +-
 2 files changed, 22 insertions(+), 1 deletion(-)

diff --git a/CHANGELOG.md b/CHANGELOG.md
index 03e8603b..048252a7 100644
--- a/CHANGELOG.md
+++ b/CHANGELOG.md
@@ -2,6 +2,27 @@
 
 All notable changes to this project will be documented in this file. See [standard-version](https://github.com/conventional-changelog/standard-version) for commit guidelines.
 
+<a name="0.28.1"></a>
+## [0.28.1](https://github.com/webpack/css-loader/compare/v0.28.0...v0.28.1) (2017-05-02)
+
+
+### Bug Fixes
+
+* allow to specify a full hostname as a root URL ([#521](https://github.com/webpack/css-loader/issues/521)) ([06d27a1](https://github.com/webpack/css-loader/commit/06d27a1))
+* case insensitivity of [@import](https://github.com/import) ([#514](https://github.com/webpack/css-loader/issues/514)) ([de4356b](https://github.com/webpack/css-loader/commit/de4356b))
+* don't handle empty [@import](https://github.com/import) and url() ([#513](https://github.com/webpack/css-loader/issues/513)) ([868fc94](https://github.com/webpack/css-loader/commit/868fc94))
+* imported variables are replaced in exports if followed by a comma ([#504](https://github.com/webpack/css-loader/issues/504)) ([956bad7](https://github.com/webpack/css-loader/commit/956bad7))
+* loader now correctly handles `url` with space(s) ([#495](https://github.com/webpack/css-loader/issues/495)) ([534ea55](https://github.com/webpack/css-loader/commit/534ea55))
+* url with a trailing space is now handled correctly ([#494](https://github.com/webpack/css-loader/issues/494)) ([e1ec4f2](https://github.com/webpack/css-loader/commit/e1ec4f2))
+* use `btoa` instead `Buffer` ([#501](https://github.com/webpack/css-loader/issues/501)) ([fbb0714](https://github.com/webpack/css-loader/commit/fbb0714))
+
+
+### Performance Improvements
+
+* generate source maps only when explicitly set ([#478](https://github.com/webpack/css-loader/issues/478)) ([b8f5c8f](https://github.com/webpack/css-loader/commit/b8f5c8f))
+
+
+
 <a name="0.28.0"></a>
 # [0.28.0](https://github.com/webpack/css-loader/compare/v0.27.3...v0.28.0) (2017-03-30)
 
diff --git a/package.json b/package.json
index 13ab19c9..43dd2c09 100644
--- a/package.json
+++ b/package.json
@@ -1,6 +1,6 @@
 {
   "name": "css-loader",
-  "version": "0.28.0",
+  "version": "0.28.1",
   "author": "Tobias Koppers @sokra",
   "description": "css loader module for webpack",
   "engines": {