css-loader 0.26.2 → 0.26.4

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/README.md CHANGED
@@ -23,6 +23,8 @@ npm install --save-dev css-loader
23
23
 
24
24
  <h2 align="center">Usage</h2>
25
25
 
26
+ The `css-loader` interprets `@import` and `url()` like `requires`.
27
+
26
28
  Use the loader either via your webpack config, CLI or inline.
27
29
 
28
30
  ### Via webpack config (recommended)
@@ -88,7 +90,7 @@ To be compatible with existing css files (if not in CSS Module mode):
88
90
  |**`camelCase`**|`false`|Export Classnames in CamelCase|
89
91
  |**`importLoaders`**|`0`|Number of loaders applied before CSS loader|
90
92
 
91
- This webpack config can load CSS files, embed small png images as Data URLs and JPG images as files.
93
+ 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.
92
94
 
93
95
  **webpack.config.js**
94
96
  ```js
@@ -100,12 +102,11 @@ module.exports = {
100
102
  use: [ 'style-loader', 'css-loader' ]
101
103
  },
102
104
  {
103
- test: /\.png$/,
104
- use: { loader: 'url-loader', options: { limit: 100000 } },
105
- },
106
- {
107
- test: /\.jpg$/,
108
- use: [ 'file-loader' ]
105
+ test: /\.(png|jpg|gif|svg|eot|ttf|woff|woff2)$/,
106
+ loader: 'url-loader',
107
+ options: {
108
+ limit: 10000
109
+ }
109
110
  }
110
111
  ]
111
112
  }
@@ -14,14 +14,23 @@ module.exports = function compileExports(result, importItemMatcher, camelCaseKey
14
14
  var exportJs = Object.keys(result.exports).reduce(function(res, key) {
15
15
  var valueAsString = JSON.stringify(result.exports[key]);
16
16
  valueAsString = valueAsString.replace(result.importItemRegExpG, importItemMatcher);
17
- res.push("\t" + JSON.stringify(key) + ": " + valueAsString);
17
+ function addEntry(k) {
18
+ res.push("\t" + JSON.stringify(k) + ": " + valueAsString);
19
+ }
20
+ addEntry(key);
18
21
 
22
+ var targetKey;
19
23
  if (camelCaseKeys === true) {
20
- res.push("\t" + JSON.stringify(camelCase(key)) + ": " + valueAsString);
24
+ targetKey = camelCase(key);
25
+ if (targetKey !== key) {
26
+ addEntry(targetKey);
27
+ }
21
28
  } else if (camelCaseKeys === 'dashes') {
22
- res.push("\t" + JSON.stringify(dashesCamelCase(key)) + ": " + valueAsString);
29
+ targetKey = dashesCamelCase(key);
30
+ if (targetKey !== key) {
31
+ addEntry(targetKey);
32
+ }
23
33
  }
24
-
25
34
  return res;
26
35
  }, []).join(",\n");
27
36
 
package/lib/loader.js CHANGED
@@ -2,7 +2,6 @@
2
2
  MIT License http://www.opensource.org/licenses/mit-license.php
3
3
  Author Tobias Koppers @sokra
4
4
  */
5
- var path = require("path");
6
5
  var loaderUtils = require("loader-utils");
7
6
  var processCss = require("./processCss");
8
7
  var getImportPrefix = require("./getImportPrefix");
@@ -97,13 +96,9 @@ module.exports = function(content, map) {
97
96
  map = result.map;
98
97
  if(map.sources) {
99
98
  map.sources = map.sources.map(function(source) {
100
- source = source.split("!").pop();
101
- var p = path.relative(query.context || this.options.context, source).replace(/\\/g, "/");
102
- if(p.indexOf("../") !== 0)
103
- p = "./" + p;
104
- return "/" + p;
99
+ return source.split("!").pop();
105
100
  }, this);
106
- map.sourceRoot = "webpack://";
101
+ map.sourceRoot = "";
107
102
  }
108
103
  map.file = map.file.split("!").pop();
109
104
  map = JSON.stringify(map);
package/package.json CHANGED
@@ -1,12 +1,16 @@
1
1
  {
2
2
  "name": "css-loader",
3
- "version": "0.26.2",
3
+ "version": "0.26.4",
4
4
  "author": "Tobias Koppers @sokra",
5
5
  "description": "css loader module for webpack",
6
6
  "engines": {
7
7
  "node": ">=0.12.0 || >=4.3.0 <5.0.0 || >=5.10"
8
8
  },
9
- "files": ["index.js", "locals.js", "lib"],
9
+ "files": [
10
+ "index.js",
11
+ "locals.js",
12
+ "lib"
13
+ ],
10
14
  "dependencies": {
11
15
  "babel-code-frame": "^6.11.0",
12
16
  "css-selector-tokenizer": "^0.7.0",