diff --git a/README.md b/README.md
index c0a70621..c4aadb6d 100644
--- a/README.md
+++ b/README.md
@@ -23,6 +23,8 @@ npm install --save-dev css-loader
Usage
+The `css-loader` interprets `@import` and `url()` like `requires`.
+
Use the loader either via your webpack config, CLI or inline.
### Via webpack config (recommended)
@@ -88,7 +90,7 @@ To be compatible with existing css files (if not in CSS Module mode):
|**`camelCase`**|`false`|Export Classnames in CamelCase|
|**`importLoaders`**|`0`|Number of loaders applied before CSS loader|
-This webpack config can load CSS files, embed small png images as Data URLs and JPG images as files.
+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.
**webpack.config.js**
```js
@@ -100,12 +102,11 @@ module.exports = {
use: [ 'style-loader', 'css-loader' ]
},
{
- test: /\.png$/,
- use: { loader: 'url-loader', options: { limit: 100000 } },
- },
- {
- test: /\.jpg$/,
- use: [ 'file-loader' ]
+ test: /\.(png|jpg|gif|svg|eot|ttf|woff|woff2)$/,
+ loader: 'url-loader',
+ options: {
+ limit: 10000
+ }
}
]
}
diff --git a/lib/loader.js b/lib/loader.js
index 561cf5a1..edf273fd 100644
--- a/lib/loader.js
+++ b/lib/loader.js
@@ -2,7 +2,6 @@
MIT License http://www.opensource.org/licenses/mit-license.php
Author Tobias Koppers @sokra
*/
-var path = require("path");
var loaderUtils = require("loader-utils");
var processCss = require("./processCss");
var getImportPrefix = require("./getImportPrefix");
@@ -97,13 +96,9 @@ module.exports = function(content, map) {
map = result.map;
if(map.sources) {
map.sources = map.sources.map(function(source) {
- source = source.split("!").pop();
- var p = path.relative(query.context || this.options.context, source).replace(/\\/g, "/");
- if(p.indexOf("../") !== 0)
- p = "./" + p;
- return "/" + p;
+ return source.split("!").pop();
}, this);
- map.sourceRoot = "webpack://";
+ map.sourceRoot = "";
}
map.file = map.file.split("!").pop();
map = JSON.stringify(map);
diff --git a/test/sourceMapTest.js b/test/sourceMapTest.js
index 9c29729a..39401e95 100644
--- a/test/sourceMapTest.js
+++ b/test/sourceMapTest.js
@@ -21,8 +21,8 @@ describe("source maps", function() {
file: 'test.css',
mappings: 'AAAA,SAAS,SAAS,EAAE',
names: [],
- sourceRoot: 'webpack://',
- sources: [ '/./folder/test.css' ],
+ sourceRoot: '',
+ sources: [ '/folder/test.css' ],
sourcesContent: [ '.class { a: b c d; }' ],
version: 3
}]
@@ -38,8 +38,8 @@ describe("source maps", function() {
file: 'test.css',
mappings: 'AAAA,SAAS,SAAS,EAAE',
names: [],
- sourceRoot: 'webpack://',
- sources: [ '/../../folder/test.css' ],
+ sourceRoot: '',
+ sources: [ '/folder/test.css' ],
sourcesContent: [ '.class { a: b c d; }' ],
version: 3
}]
@@ -55,8 +55,8 @@ describe("source maps", function() {
file: 'test.scss',
mappings: 'AAAA,SAAS,SAAS,EAAE',
names: [],
- sourceRoot: 'webpack://',
- sources: [ '/./folder/test.scss' ],
+ sourceRoot: '',
+ sources: [ '/folder/test.scss' ],
sourcesContent: [ '.class { a: b c d; }' ],
version: 3
}]