css-loader 0.28.7 → 0.28.8
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 +11 -0
- package/README.md +11 -11
- package/lib/loader.js +14 -8
- package/lib/processCss.js +2 -4
- package/lib/url/escape.js +13 -0
- package/package.json +18 -19
package/CHANGELOG.md
CHANGED
|
@@ -2,6 +2,17 @@
|
|
|
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.8"></a>
|
|
6
|
+
## [0.28.8](https://github.com/webpack-contrib/css-loader/compare/v0.28.7...v0.28.8) (2018-01-05)
|
|
7
|
+
|
|
8
|
+
|
|
9
|
+
### Bug Fixes
|
|
10
|
+
|
|
11
|
+
* **loader:** correctly check if source map is `undefined` ([#641](https://github.com/webpack-contrib/css-loader/issues/641)) ([0dccfa9](https://github.com/webpack-contrib/css-loader/commit/0dccfa9))
|
|
12
|
+
* proper URL escaping and wrapping (`url()`) ([#627](https://github.com/webpack-contrib/css-loader/issues/627)) ([8897d44](https://github.com/webpack-contrib/css-loader/commit/8897d44))
|
|
13
|
+
|
|
14
|
+
|
|
15
|
+
|
|
5
16
|
<a name="0.28.7"></a>
|
|
6
17
|
## [0.28.7](https://github.com/webpack/css-loader/compare/v0.28.6...v0.28.7) (2017-08-30)
|
|
7
18
|
|
package/README.md
CHANGED
|
@@ -94,15 +94,15 @@ It's useful when you, for instance, need to post process the CSS as a string.
|
|
|
94
94
|
|
|
95
95
|
|Name|Type|Default|Description|
|
|
96
96
|
|:--:|:--:|:-----:|:----------|
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
97
|
+
|**[`root`](#root)**|`{String}`|`/`|Path to resolve URLs, URLs starting with `/` will not be translated|
|
|
98
|
+
|**[`url`](#url)**|`{Boolean}`|`true`| Enable/Disable `url()` handling|
|
|
99
|
+
|**[`alias`](#alias)**|`{Object}`|`{}`|Create aliases to import certain modules more easily|
|
|
100
|
+
|**[`import`](#import)** |`{Boolean}`|`true`| Enable/Disable @import handling|
|
|
101
|
+
|**[`modules`](#modules)**|`{Boolean}`|`false`|Enable/Disable CSS Modules|
|
|
102
|
+
|**[`minimize`](#minimize)**|`{Boolean\|Object}`|`false`|Enable/Disable minification|
|
|
103
|
+
|**[`sourceMap`](#sourcemap)**|`{Boolean}`|`false`|Enable/Disable Sourcemaps|
|
|
104
|
+
|**[`camelCase`](#camelcase)**|`{Boolean\|String}`|`false`|Export Classnames in CamelCase|
|
|
105
|
+
|**[`importLoaders`](#importloaders)**|`{Number}`|`0`|Number of loaders applied before CSS loader|
|
|
106
106
|
|**`localIdentName`**|`{String}`|`[hash:base64]`|Configure the generated ident|
|
|
107
107
|
|
|
108
108
|
### `root`
|
|
@@ -141,7 +141,7 @@ url(~module/image.png) => require('module/image.png')
|
|
|
141
141
|
|
|
142
142
|
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.).
|
|
143
143
|
|
|
144
|
-
`css-loader`'s `alias` follows the same syntax as webpack's `resolve.alias`, you can see the details at the [resolve docs]
|
|
144
|
+
`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)
|
|
145
145
|
|
|
146
146
|
**file.scss**
|
|
147
147
|
```css
|
|
@@ -419,7 +419,7 @@ The query parameter `importLoaders` allows to configure how many loaders before
|
|
|
419
419
|
{
|
|
420
420
|
loader: 'css-loader',
|
|
421
421
|
options: {
|
|
422
|
-
importLoaders:
|
|
422
|
+
importLoaders: 2 // 0 => no loaders (default); 1 => postcss-loader; 2 => postcss-loader, sass-loader
|
|
423
423
|
}
|
|
424
424
|
},
|
|
425
425
|
'postcss-loader',
|
package/lib/loader.js
CHANGED
|
@@ -83,7 +83,13 @@ module.exports = function(content, map) {
|
|
|
83
83
|
}
|
|
84
84
|
|
|
85
85
|
cssAsString = cssAsString.replace(result.importItemRegExpG, importItemMatcher.bind(this));
|
|
86
|
-
|
|
86
|
+
|
|
87
|
+
// helper for ensuring valid CSS strings from requires
|
|
88
|
+
var urlEscapeHelper = "";
|
|
89
|
+
|
|
90
|
+
if(query.url !== false && result.urlItems.length > 0) {
|
|
91
|
+
urlEscapeHelper = "var escape = require(" + loaderUtils.stringifyRequest(this, require.resolve("./url/escape.js")) + ");\n";
|
|
92
|
+
|
|
87
93
|
cssAsString = cssAsString.replace(result.urlItemRegExpG, function(item) {
|
|
88
94
|
var match = result.urlItemRegExp.exec(item);
|
|
89
95
|
var idx = +match[1];
|
|
@@ -95,22 +101,21 @@ module.exports = function(content, map) {
|
|
|
95
101
|
if(idx > 0) { // idx === 0 is catched by isUrlRequest
|
|
96
102
|
// in cases like url('webfont.eot?#iefix')
|
|
97
103
|
urlRequest = url.substr(0, idx);
|
|
98
|
-
return "\" + require(" + loaderUtils.stringifyRequest(this, urlRequest) + ") + \"" +
|
|
104
|
+
return "\" + escape(require(" + loaderUtils.stringifyRequest(this, urlRequest) + ")) + \"" +
|
|
99
105
|
url.substr(idx);
|
|
100
106
|
}
|
|
101
107
|
urlRequest = url;
|
|
102
|
-
return "\" + require(" + loaderUtils.stringifyRequest(this, urlRequest) + ") + \"";
|
|
108
|
+
return "\" + escape(require(" + loaderUtils.stringifyRequest(this, urlRequest) + ")) + \"";
|
|
103
109
|
}.bind(this));
|
|
104
110
|
}
|
|
105
|
-
|
|
106
|
-
|
|
111
|
+
|
|
107
112
|
var exportJs = compileExports(result, importItemMatcher.bind(this), camelCaseKeys);
|
|
108
113
|
if (exportJs) {
|
|
109
114
|
exportJs = "exports.locals = " + exportJs + ";";
|
|
110
115
|
}
|
|
111
116
|
|
|
112
117
|
var moduleJs;
|
|
113
|
-
if(
|
|
118
|
+
if(sourceMap && result.map) {
|
|
114
119
|
// add a SourceMap
|
|
115
120
|
map = result.map;
|
|
116
121
|
if(map.sources) {
|
|
@@ -127,9 +132,10 @@ module.exports = function(content, map) {
|
|
|
127
132
|
}
|
|
128
133
|
|
|
129
134
|
// embed runtime
|
|
130
|
-
callback(null,
|
|
135
|
+
callback(null, urlEscapeHelper +
|
|
136
|
+
"exports = module.exports = require(" +
|
|
131
137
|
loaderUtils.stringifyRequest(this, require.resolve("./css-base.js")) +
|
|
132
|
-
")(" +
|
|
138
|
+
")(" + sourceMap + ");\n" +
|
|
133
139
|
"// imports\n" +
|
|
134
140
|
importJs + "\n\n" +
|
|
135
141
|
"// module\n" +
|
package/lib/processCss.js
CHANGED
|
@@ -104,10 +104,8 @@ var parserPlugin = postcss.plugin("css-loader-parser", function(options) {
|
|
|
104
104
|
break;
|
|
105
105
|
case "url":
|
|
106
106
|
if (options.url && item.url.replace(/\s/g, '').length && !/^#/.test(item.url) && (isAlias(item.url) || loaderUtils.isUrlRequest(item.url, options.root))) {
|
|
107
|
-
//
|
|
108
|
-
|
|
109
|
-
item.stringType = "";
|
|
110
|
-
}
|
|
107
|
+
// Strip quotes, they will be re-added if the module needs them
|
|
108
|
+
item.stringType = "";
|
|
111
109
|
delete item.innerSpacingBefore;
|
|
112
110
|
delete item.innerSpacingAfter;
|
|
113
111
|
var url = item.url;
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
module.exports = function escape(url) {
|
|
2
|
+
// If url is already wrapped in quotes, remove them
|
|
3
|
+
if (/^['"].*['"]$/.test(url)) {
|
|
4
|
+
url = url.slice(1, -1);
|
|
5
|
+
}
|
|
6
|
+
// Should url be wrapped?
|
|
7
|
+
// See https://drafts.csswg.org/css-values-3/#urls
|
|
8
|
+
if (/["'() \t\n]/.test(url)) {
|
|
9
|
+
return '"' + url.replace(/"/g, '\\"').replace(/\n/g, '\\n') + '"'
|
|
10
|
+
}
|
|
11
|
+
|
|
12
|
+
return url
|
|
13
|
+
}
|
package/package.json
CHANGED
|
@@ -1,29 +1,30 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "css-loader",
|
|
3
|
-
"version": "0.28.
|
|
3
|
+
"version": "0.28.8",
|
|
4
4
|
"author": "Tobias Koppers @sokra",
|
|
5
|
+
"license": "MIT",
|
|
5
6
|
"description": "css loader module for webpack",
|
|
6
7
|
"engines": {
|
|
7
|
-
"node": ">=0.12.0 || >=4.3.0 <5.0.0 || >=5.10"
|
|
8
|
+
"node": ">=0.12.0 || >= 4.3.0 < 5.0.0 || >=5.10"
|
|
8
9
|
},
|
|
9
10
|
"files": [
|
|
11
|
+
"lib",
|
|
10
12
|
"index.js",
|
|
11
|
-
"locals.js"
|
|
12
|
-
"lib"
|
|
13
|
+
"locals.js"
|
|
13
14
|
],
|
|
14
15
|
"dependencies": {
|
|
15
|
-
"babel-code-frame": "^6.
|
|
16
|
+
"babel-code-frame": "^6.26.0",
|
|
16
17
|
"css-selector-tokenizer": "^0.7.0",
|
|
17
|
-
"cssnano": "
|
|
18
|
+
"cssnano": "^3.10.0",
|
|
18
19
|
"icss-utils": "^2.1.0",
|
|
19
20
|
"loader-utils": "^1.0.2",
|
|
20
21
|
"lodash.camelcase": "^4.3.0",
|
|
21
|
-
"object-assign": "^4.
|
|
22
|
+
"object-assign": "^4.1.1",
|
|
22
23
|
"postcss": "^5.0.6",
|
|
23
|
-
"postcss-modules-extract-imports": "^1.
|
|
24
|
-
"postcss-modules-local-by-default": "^1.0
|
|
25
|
-
"postcss-modules-scope": "^1.
|
|
26
|
-
"postcss-modules-values": "^1.
|
|
24
|
+
"postcss-modules-extract-imports": "^1.1.0",
|
|
25
|
+
"postcss-modules-local-by-default": "^1.2.0",
|
|
26
|
+
"postcss-modules-scope": "^1.1.0",
|
|
27
|
+
"postcss-modules-values": "^1.3.0",
|
|
27
28
|
"postcss-value-parser": "^3.3.0",
|
|
28
29
|
"source-list-map": "^2.0.0"
|
|
29
30
|
},
|
|
@@ -36,17 +37,15 @@
|
|
|
36
37
|
"standard-version": "^4.0.0"
|
|
37
38
|
},
|
|
38
39
|
"scripts": {
|
|
40
|
+
"lint": "eslint lib test",
|
|
39
41
|
"test": "mocha",
|
|
42
|
+
"cover": "istanbul cover node_modules/mocha/bin/_mocha",
|
|
40
43
|
"test:cover": "npm run cover -- --report lcovonly",
|
|
41
|
-
"lint": "eslint lib test",
|
|
42
44
|
"travis:test": "npm run cover",
|
|
43
45
|
"travis:lint": "npm run lint",
|
|
44
|
-
"
|
|
45
|
-
"release": "yarn run standard-version"
|
|
46
|
-
},
|
|
47
|
-
"repository": {
|
|
48
|
-
"type": "git",
|
|
49
|
-
"url": "git@github.com:webpack/css-loader.git"
|
|
46
|
+
"release": "standard-version"
|
|
50
47
|
},
|
|
51
|
-
"
|
|
48
|
+
"homepage": "https://github.com/webpack-contrib/css-loader",
|
|
49
|
+
"repository": "https://github.com/webpack-contrib/css-loader.git",
|
|
50
|
+
"bugs": "https://github.com/webpack-contrib/css-loader/issues"
|
|
52
51
|
}
|