css-loader 0.28.3 → 0.28.7
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/CHANGELOG.md +41 -0
- package/README.md +3 -3
- package/lib/compile-exports.js +1 -1
- package/lib/loader.js +1 -0
- package/lib/localsLoader.js +4 -1
- package/lib/processCss.js +22 -22
- package/package.json +3 -2
package/CHANGELOG.md
CHANGED
|
@@ -2,6 +2,47 @@
|
|
|
2
2
|
|
|
3
3
|
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.
|
|
4
4
|
|
|
5
|
+
<a name="0.28.7"></a>
|
|
6
|
+
## [0.28.7](https://github.com/webpack/css-loader/compare/v0.28.6...v0.28.7) (2017-08-30)
|
|
7
|
+
|
|
8
|
+
|
|
9
|
+
### Bug Fixes
|
|
10
|
+
|
|
11
|
+
* pass resolver to `localsLoader` (`options.alias`) ([#601](https://github.com/webpack/css-loader/issues/601)) ([8f1b57c](https://github.com/webpack/css-loader/commit/8f1b57c))
|
|
12
|
+
|
|
13
|
+
|
|
14
|
+
|
|
15
|
+
<a name="0.28.6"></a>
|
|
16
|
+
## [0.28.6](https://github.com/webpack/css-loader/compare/v0.28.5...v0.28.6) (2017-08-30)
|
|
17
|
+
|
|
18
|
+
|
|
19
|
+
### Bug Fixes
|
|
20
|
+
|
|
21
|
+
* add support for aliases starting with `/` (`options.alias`) ([#597](https://github.com/webpack/css-loader/issues/597)) ([63567f2](https://github.com/webpack/css-loader/commit/63567f2))
|
|
22
|
+
|
|
23
|
+
|
|
24
|
+
|
|
25
|
+
<a name="0.28.5"></a>
|
|
26
|
+
## [0.28.5](https://github.com/webpack/css-loader/compare/v0.28.4...v0.28.5) (2017-08-17)
|
|
27
|
+
|
|
28
|
+
|
|
29
|
+
### Bug Fixes
|
|
30
|
+
|
|
31
|
+
* match mutliple dashes (`options.camelCase`) ([#556](https://github.com/webpack/css-loader/issues/556)) ([1fee601](https://github.com/webpack/css-loader/commit/1fee601))
|
|
32
|
+
* stricter `[@import](https://github.com/import)` tolerance ([#593](https://github.com/webpack/css-loader/issues/593)) ([2e4ec09](https://github.com/webpack/css-loader/commit/2e4ec09))
|
|
33
|
+
|
|
34
|
+
|
|
35
|
+
|
|
36
|
+
<a name="0.28.4"></a>
|
|
37
|
+
## [0.28.4](https://github.com/webpack/css-loader/compare/v0.28.3...v0.28.4) (2017-05-30)
|
|
38
|
+
|
|
39
|
+
|
|
40
|
+
### Bug Fixes
|
|
41
|
+
|
|
42
|
+
* preserve leading underscore in class names ([#543](https://github.com/webpack/css-loader/issues/543)) ([f6673c8](https://github.com/webpack/css-loader/commit/f6673c8))
|
|
43
|
+
|
|
44
|
+
|
|
45
|
+
|
|
5
46
|
<a name="0.28.3"></a>
|
|
6
47
|
## [0.28.3](https://github.com/webpack/css-loader/compare/v0.28.2...v0.28.3) (2017-05-25)
|
|
7
48
|
|
package/README.md
CHANGED
|
@@ -27,7 +27,7 @@ The `css-loader` interprets `@import` and `url()` like `import/require()`
|
|
|
27
27
|
and will resolve them.
|
|
28
28
|
|
|
29
29
|
Good loaders for requiring your assets are the [file-loader](https://github.com/webpack/file-loader)
|
|
30
|
-
and the [url-loader](https://github.com/webpack/url-loader) which you should specify in your config (see [below](https://github.com/
|
|
30
|
+
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#assets)).
|
|
31
31
|
|
|
32
32
|
**file.js**
|
|
33
33
|
```js
|
|
@@ -103,6 +103,7 @@ It's useful when you, for instance, need to post process the CSS as a string.
|
|
|
103
103
|
|**`sourceMap`**|`{Boolean}`|`false`|Enable/Disable Sourcemaps|
|
|
104
104
|
|**`camelCase`**|`{Boolean\|String}`|`false`|Export Classnames in CamelCase|
|
|
105
105
|
|**`importLoaders`**|`{Number}`|`0`|Number of loaders applied before CSS loader|
|
|
106
|
+
|**`localIdentName`**|`{String}`|`[hash:base64]`|Configure the generated ident|
|
|
106
107
|
|
|
107
108
|
### `root`
|
|
108
109
|
|
|
@@ -342,7 +343,7 @@ To import from multiple modules use multiple `composes:` rules.
|
|
|
342
343
|
|
|
343
344
|
By default the css-loader minimizes the css if specified by the module system.
|
|
344
345
|
|
|
345
|
-
In some cases the minification is destructive to the css, so you can provide your own options to the minifier if needed.
|
|
346
|
+
In some cases the minification is destructive to the css, so you can provide your own options to the cssnano-based minifier if needed. See [cssnano's documentation](http://cssnano.co/guides/) for more information on the available options.
|
|
346
347
|
|
|
347
348
|
You can also disable or enforce minification with the `minimize` query parameter.
|
|
348
349
|
|
|
@@ -487,7 +488,6 @@ module.exports = {
|
|
|
487
488
|
})
|
|
488
489
|
]
|
|
489
490
|
: []
|
|
490
|
-
]
|
|
491
491
|
}
|
|
492
492
|
```
|
|
493
493
|
|
package/lib/compile-exports.js
CHANGED
package/lib/loader.js
CHANGED
|
@@ -42,6 +42,7 @@ module.exports = function(content, map) {
|
|
|
42
42
|
from: loaderUtils.getRemainingRequest(this).split("!").pop(),
|
|
43
43
|
to: loaderUtils.getCurrentRequest(this).split("!").pop(),
|
|
44
44
|
query: query,
|
|
45
|
+
resolve: resolve,
|
|
45
46
|
minimize: this.minimize,
|
|
46
47
|
loaderContext: this,
|
|
47
48
|
sourceMap: sourceMap
|
package/lib/localsLoader.js
CHANGED
|
@@ -6,6 +6,7 @@ var loaderUtils = require("loader-utils");
|
|
|
6
6
|
var processCss = require("./processCss");
|
|
7
7
|
var getImportPrefix = require("./getImportPrefix");
|
|
8
8
|
var compileExports = require("./compile-exports");
|
|
9
|
+
var createResolver = require("./createResolver");
|
|
9
10
|
|
|
10
11
|
|
|
11
12
|
module.exports = function(content) {
|
|
@@ -14,12 +15,14 @@ module.exports = function(content) {
|
|
|
14
15
|
var query = loaderUtils.getOptions(this) || {};
|
|
15
16
|
var moduleMode = query.modules || query.module;
|
|
16
17
|
var camelCaseKeys = query.camelCase || query.camelcase;
|
|
18
|
+
var resolve = createResolver(query.alias);
|
|
17
19
|
|
|
18
20
|
processCss(content, null, {
|
|
19
21
|
mode: moduleMode ? "local" : "global",
|
|
20
22
|
query: query,
|
|
21
23
|
minimize: this.minimize,
|
|
22
|
-
loaderContext: this
|
|
24
|
+
loaderContext: this,
|
|
25
|
+
resolve: resolve
|
|
23
26
|
}, function(err, result) {
|
|
24
27
|
if(err) return callback(err);
|
|
25
28
|
|
package/lib/processCss.js
CHANGED
|
@@ -9,6 +9,7 @@ var loaderUtils = require("loader-utils");
|
|
|
9
9
|
var assign = require("object-assign");
|
|
10
10
|
var getLocalIdent = require("./getLocalIdent");
|
|
11
11
|
|
|
12
|
+
var icssUtils = require('icss-utils');
|
|
12
13
|
var localByDefault = require("postcss-modules-local-by-default");
|
|
13
14
|
var extractImports = require("postcss-modules-extract-imports");
|
|
14
15
|
var modulesScope = require("postcss-modules-scope");
|
|
@@ -41,12 +42,12 @@ var parserPlugin = postcss.plugin("css-loader-parser", function(options) {
|
|
|
41
42
|
}
|
|
42
43
|
|
|
43
44
|
if(options.import) {
|
|
44
|
-
css.walkAtRules(
|
|
45
|
+
css.walkAtRules(/^import$/i, function(rule) {
|
|
45
46
|
var values = Tokenizer.parseValues(rule.params);
|
|
46
47
|
var url = values.nodes[0].nodes[0];
|
|
47
|
-
if(url.type === "url") {
|
|
48
|
+
if(url && url.type === "url") {
|
|
48
49
|
url = url.url;
|
|
49
|
-
} else if(url.type === "string") {
|
|
50
|
+
} else if(url && url.type === "string") {
|
|
50
51
|
url = url.value;
|
|
51
52
|
} else throw rule.error("Unexpected format " + rule.params);
|
|
52
53
|
if (!url.replace(/\s/g, '').length) {
|
|
@@ -65,30 +66,28 @@ var parserPlugin = postcss.plugin("css-loader-parser", function(options) {
|
|
|
65
66
|
});
|
|
66
67
|
}
|
|
67
68
|
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
rule.walkDecls(function(decl) {
|
|
78
|
-
imports["$" + decl.prop] = importItems.length;
|
|
79
|
-
importItems.push({
|
|
80
|
-
url: url,
|
|
81
|
-
export: decl.value
|
|
82
|
-
});
|
|
69
|
+
var icss = icssUtils.extractICSS(css);
|
|
70
|
+
exports = icss.icssExports;
|
|
71
|
+
Object.keys(icss.icssImports).forEach(function(key) {
|
|
72
|
+
var url = loaderUtils.parseString(key);
|
|
73
|
+
Object.keys(icss.icssImports[key]).forEach(function(prop) {
|
|
74
|
+
imports["$" + prop] = importItems.length;
|
|
75
|
+
importItems.push({
|
|
76
|
+
url: url,
|
|
77
|
+
export: icss.icssImports[key][prop]
|
|
83
78
|
});
|
|
84
|
-
|
|
85
|
-
}
|
|
79
|
+
})
|
|
86
80
|
});
|
|
87
81
|
|
|
88
82
|
Object.keys(exports).forEach(function(exportName) {
|
|
89
83
|
exports[exportName] = replaceImportsInString(exports[exportName]);
|
|
90
84
|
});
|
|
91
85
|
|
|
86
|
+
function isAlias(url) {
|
|
87
|
+
// Handle alias starting by / and root disabled
|
|
88
|
+
return url !== options.resolve(url)
|
|
89
|
+
}
|
|
90
|
+
|
|
92
91
|
function processNode(item) {
|
|
93
92
|
switch (item.type) {
|
|
94
93
|
case "value":
|
|
@@ -104,7 +103,7 @@ var parserPlugin = postcss.plugin("css-loader-parser", function(options) {
|
|
|
104
103
|
}
|
|
105
104
|
break;
|
|
106
105
|
case "url":
|
|
107
|
-
if (options.url && item.url.replace(/\s/g, '').length && !/^#/.test(item.url) && loaderUtils.isUrlRequest(item.url, options.root)) {
|
|
106
|
+
if (options.url && item.url.replace(/\s/g, '').length && !/^#/.test(item.url) && (isAlias(item.url) || loaderUtils.isUrlRequest(item.url, options.root))) {
|
|
108
107
|
// Don't remove quotes around url when contain space
|
|
109
108
|
if (item.url.indexOf(" ") === -1) {
|
|
110
109
|
item.stringType = "";
|
|
@@ -155,7 +154,8 @@ module.exports = function processCss(inputSource, inputMap, options, callback) {
|
|
|
155
154
|
root: root,
|
|
156
155
|
mode: options.mode,
|
|
157
156
|
url: query.url !== false,
|
|
158
|
-
import: query.import !== false
|
|
157
|
+
import: query.import !== false,
|
|
158
|
+
resolve: options.resolve
|
|
159
159
|
};
|
|
160
160
|
|
|
161
161
|
var pipeline = postcss([
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "css-loader",
|
|
3
|
-
"version": "0.28.
|
|
3
|
+
"version": "0.28.7",
|
|
4
4
|
"author": "Tobias Koppers @sokra",
|
|
5
5
|
"description": "css loader module for webpack",
|
|
6
6
|
"engines": {
|
|
@@ -15,6 +15,7 @@
|
|
|
15
15
|
"babel-code-frame": "^6.11.0",
|
|
16
16
|
"css-selector-tokenizer": "^0.7.0",
|
|
17
17
|
"cssnano": ">=2.6.1 <4",
|
|
18
|
+
"icss-utils": "^2.1.0",
|
|
18
19
|
"loader-utils": "^1.0.2",
|
|
19
20
|
"lodash.camelcase": "^4.3.0",
|
|
20
21
|
"object-assign": "^4.0.1",
|
|
@@ -24,7 +25,7 @@
|
|
|
24
25
|
"postcss-modules-scope": "^1.0.0",
|
|
25
26
|
"postcss-modules-values": "^1.1.0",
|
|
26
27
|
"postcss-value-parser": "^3.3.0",
|
|
27
|
-
"source-list-map": "^0.
|
|
28
|
+
"source-list-map": "^2.0.0"
|
|
28
29
|
},
|
|
29
30
|
"devDependencies": {
|
|
30
31
|
"codecov": "^1.0.1",
|