css-loader 3.5.0 → 3.6.0
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 +29 -0
- package/README.md +28 -4
- package/dist/index.js +6 -2
- package/dist/options.json +4 -1
- package/dist/utils.js +21 -16
- package/package.json +20 -22
package/CHANGELOG.md
CHANGED
|
@@ -2,6 +2,35 @@
|
|
|
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
|
+
## [3.6.0](https://github.com/webpack-contrib/css-loader/compare/v3.5.3...v3.6.0) (2020-06-13)
|
|
6
|
+
|
|
7
|
+
|
|
8
|
+
### Features
|
|
9
|
+
|
|
10
|
+
* allow `modules.auto` to be a filter function ([#1086](https://github.com/webpack-contrib/css-loader/issues/1086)) ([0902353](https://github.com/webpack-contrib/css-loader/commit/0902353c328d4d18e8ed2755fe9c83c03c53df81))
|
|
11
|
+
|
|
12
|
+
### [3.5.3](https://github.com/webpack-contrib/css-loader/compare/v3.5.2...v3.5.3) (2020-04-24)
|
|
13
|
+
|
|
14
|
+
|
|
15
|
+
### Bug Fixes
|
|
16
|
+
|
|
17
|
+
* add file from an error to file dependencies ([841423f](https://github.com/webpack-contrib/css-loader/commit/841423fca2932c18f8ac0cf0a1f0012fc0a62fb6))
|
|
18
|
+
* avoid query string in source maps ([#1082](https://github.com/webpack-contrib/css-loader/issues/1082)) ([f64de13](https://github.com/webpack-contrib/css-loader/commit/f64de13f7377eff9501348cf26213212ca696913))
|
|
19
|
+
|
|
20
|
+
### [3.5.2](https://github.com/webpack-contrib/css-loader/compare/v3.5.1...v3.5.2) (2020-04-10)
|
|
21
|
+
|
|
22
|
+
|
|
23
|
+
### Bug Fixes
|
|
24
|
+
|
|
25
|
+
* schema for the `modules.auto` option ([#1075](https://github.com/webpack-contrib/css-loader/issues/1075)) ([8c9ffe7](https://github.com/webpack-contrib/css-loader/commit/8c9ffe7c6df11232b63173c757baa71ed36f6145))
|
|
26
|
+
|
|
27
|
+
### [3.5.1](https://github.com/webpack-contrib/css-loader/compare/v3.5.0...v3.5.1) (2020-04-07)
|
|
28
|
+
|
|
29
|
+
|
|
30
|
+
### Bug Fixes
|
|
31
|
+
|
|
32
|
+
* don't generate an invalid code for `locals` ([#1072](https://github.com/webpack-contrib/css-loader/issues/1072)) ([866b84a](https://github.com/webpack-contrib/css-loader/commit/866b84acd7fd47651f741ca1e6cf7081c2bbe357))
|
|
33
|
+
|
|
5
34
|
## [3.5.0](https://github.com/webpack-contrib/css-loader/compare/v3.4.2...v3.5.0) (2020-04-06)
|
|
6
35
|
|
|
7
36
|
|
package/README.md
CHANGED
|
@@ -542,7 +542,7 @@ module.exports = {
|
|
|
542
542
|
|
|
543
543
|
##### `auto`
|
|
544
544
|
|
|
545
|
-
Type: `Boolean|RegExp`
|
|
545
|
+
Type: `Boolean|RegExp|Function`
|
|
546
546
|
Default: `'undefined'`
|
|
547
547
|
|
|
548
548
|
Allows auto enable css modules based on filename.
|
|
@@ -576,7 +576,7 @@ module.exports = {
|
|
|
576
576
|
|
|
577
577
|
###### `RegExp`
|
|
578
578
|
|
|
579
|
-
Enable css modules for files based on
|
|
579
|
+
Enable css modules for files based on the filename satisfying your regex check.
|
|
580
580
|
|
|
581
581
|
**webpack.config.js**
|
|
582
582
|
|
|
@@ -598,6 +598,30 @@ module.exports = {
|
|
|
598
598
|
};
|
|
599
599
|
```
|
|
600
600
|
|
|
601
|
+
###### `Function`
|
|
602
|
+
|
|
603
|
+
Enable css modules for files based on the filename satisfying your filter function check.
|
|
604
|
+
|
|
605
|
+
**webpack.config.js**
|
|
606
|
+
|
|
607
|
+
```js
|
|
608
|
+
module.exports = {
|
|
609
|
+
module: {
|
|
610
|
+
rules: [
|
|
611
|
+
{
|
|
612
|
+
test: /\.css$/i,
|
|
613
|
+
loader: 'css-loader',
|
|
614
|
+
options: {
|
|
615
|
+
modules: {
|
|
616
|
+
auto: (resourcePath) => resourcePath.endsWith('.custom-module.css'),
|
|
617
|
+
},
|
|
618
|
+
},
|
|
619
|
+
},
|
|
620
|
+
],
|
|
621
|
+
},
|
|
622
|
+
};
|
|
623
|
+
```
|
|
624
|
+
|
|
601
625
|
##### `mode`
|
|
602
626
|
|
|
603
627
|
Type: `String|Function`
|
|
@@ -1117,8 +1141,8 @@ Please take a moment to read our contributing guidelines if you haven't yet done
|
|
|
1117
1141
|
[node-url]: https://nodejs.org
|
|
1118
1142
|
[deps]: https://david-dm.org/webpack-contrib/css-loader.svg
|
|
1119
1143
|
[deps-url]: https://david-dm.org/webpack-contrib/css-loader
|
|
1120
|
-
[tests]: https://
|
|
1121
|
-
[tests-url]: https://
|
|
1144
|
+
[tests]: https://github.com/webpack-contrib/css-loader/workflows/css-loader/badge.svg
|
|
1145
|
+
[tests-url]: https://github.com/webpack-contrib/css-loader/actions
|
|
1122
1146
|
[cover]: https://codecov.io/gh/webpack-contrib/css-loader/branch/master/graph/badge.svg
|
|
1123
1147
|
[cover-url]: https://codecov.io/gh/webpack-contrib/css-loader
|
|
1124
1148
|
[chat]: https://badges.gitter.im/webpack/webpack.svg
|
package/dist/index.js
CHANGED
|
@@ -81,8 +81,8 @@ function loader(content, map, meta) {
|
|
|
81
81
|
}
|
|
82
82
|
|
|
83
83
|
(0, _postcss.default)(plugins).process(content, {
|
|
84
|
-
from: this.
|
|
85
|
-
to: this.
|
|
84
|
+
from: this.resourcePath,
|
|
85
|
+
to: this.resourcePath,
|
|
86
86
|
map: options.sourceMap ? {
|
|
87
87
|
// Some loaders (example `"postcss-loader": "1.x.x"`) always generates source map, we should remove it
|
|
88
88
|
prev: sourceMap && map ? (0, _utils.normalizeSourceMap)(map) : null,
|
|
@@ -134,6 +134,10 @@ function loader(content, map, meta) {
|
|
|
134
134
|
const exportCode = (0, _utils.getExportCode)(exports, exportType, localsConvention, icssReplacements, esModule);
|
|
135
135
|
return callback(null, `${importCode}${moduleCode}${exportCode}`);
|
|
136
136
|
}).catch(error => {
|
|
137
|
+
if (error.file) {
|
|
138
|
+
this.addDependency(error.file);
|
|
139
|
+
}
|
|
140
|
+
|
|
137
141
|
callback(error.name === 'CssSyntaxError' ? new _CssSyntaxError.default(error) : error);
|
|
138
142
|
});
|
|
139
143
|
}
|
package/dist/options.json
CHANGED
package/dist/utils.js
CHANGED
|
@@ -124,6 +124,10 @@ function shouldUseModulesPlugins(modules, resourcePath) {
|
|
|
124
124
|
return modules.auto.test(resourcePath);
|
|
125
125
|
}
|
|
126
126
|
|
|
127
|
+
if (typeof modules.auto === 'function') {
|
|
128
|
+
return modules.auto(resourcePath);
|
|
129
|
+
}
|
|
130
|
+
|
|
127
131
|
return true;
|
|
128
132
|
}
|
|
129
133
|
|
|
@@ -300,25 +304,26 @@ function getExportCode(exports, exportType, localsConvention, icssReplacements,
|
|
|
300
304
|
let code = '';
|
|
301
305
|
let localsCode = '';
|
|
302
306
|
|
|
303
|
-
const addExportToLocalsCode = (name, value
|
|
304
|
-
|
|
305
|
-
|
|
306
|
-
|
|
307
|
+
const addExportToLocalsCode = (name, value) => {
|
|
308
|
+
if (localsCode) {
|
|
309
|
+
localsCode += `,\n`;
|
|
310
|
+
}
|
|
307
311
|
|
|
308
|
-
|
|
309
|
-
|
|
310
|
-
name,
|
|
311
|
-
value
|
|
312
|
-
} = item;
|
|
312
|
+
localsCode += `\t${JSON.stringify(name)}: ${JSON.stringify(value)}`;
|
|
313
|
+
};
|
|
313
314
|
|
|
315
|
+
for (const {
|
|
316
|
+
name,
|
|
317
|
+
value
|
|
318
|
+
} of exports) {
|
|
314
319
|
switch (localsConvention) {
|
|
315
320
|
case 'camelCase':
|
|
316
321
|
{
|
|
317
|
-
addExportToLocalsCode(name, value
|
|
322
|
+
addExportToLocalsCode(name, value);
|
|
318
323
|
const modifiedName = (0, _camelcase.default)(name);
|
|
319
324
|
|
|
320
325
|
if (modifiedName !== name) {
|
|
321
|
-
addExportToLocalsCode(modifiedName, value
|
|
326
|
+
addExportToLocalsCode(modifiedName, value);
|
|
322
327
|
}
|
|
323
328
|
|
|
324
329
|
break;
|
|
@@ -326,17 +331,17 @@ function getExportCode(exports, exportType, localsConvention, icssReplacements,
|
|
|
326
331
|
|
|
327
332
|
case 'camelCaseOnly':
|
|
328
333
|
{
|
|
329
|
-
addExportToLocalsCode((0, _camelcase.default)(name), value
|
|
334
|
+
addExportToLocalsCode((0, _camelcase.default)(name), value);
|
|
330
335
|
break;
|
|
331
336
|
}
|
|
332
337
|
|
|
333
338
|
case 'dashes':
|
|
334
339
|
{
|
|
335
340
|
addExportToLocalsCode(name, value);
|
|
336
|
-
const modifiedName = dashesCamelCase(name
|
|
341
|
+
const modifiedName = dashesCamelCase(name);
|
|
337
342
|
|
|
338
343
|
if (modifiedName !== name) {
|
|
339
|
-
addExportToLocalsCode(modifiedName, value
|
|
344
|
+
addExportToLocalsCode(modifiedName, value);
|
|
340
345
|
}
|
|
341
346
|
|
|
342
347
|
break;
|
|
@@ -344,13 +349,13 @@ function getExportCode(exports, exportType, localsConvention, icssReplacements,
|
|
|
344
349
|
|
|
345
350
|
case 'dashesOnly':
|
|
346
351
|
{
|
|
347
|
-
addExportToLocalsCode(dashesCamelCase(name), value
|
|
352
|
+
addExportToLocalsCode(dashesCamelCase(name), value);
|
|
348
353
|
break;
|
|
349
354
|
}
|
|
350
355
|
|
|
351
356
|
case 'asIs':
|
|
352
357
|
default:
|
|
353
|
-
addExportToLocalsCode(name, value
|
|
358
|
+
addExportToLocalsCode(name, value);
|
|
354
359
|
break;
|
|
355
360
|
}
|
|
356
361
|
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "css-loader",
|
|
3
|
-
"version": "3.
|
|
3
|
+
"version": "3.6.0",
|
|
4
4
|
"description": "css loader module for webpack",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"repository": "webpack-contrib/css-loader",
|
|
@@ -48,48 +48,46 @@
|
|
|
48
48
|
"icss-utils": "^4.1.1",
|
|
49
49
|
"loader-utils": "^1.2.3",
|
|
50
50
|
"normalize-path": "^3.0.0",
|
|
51
|
-
"postcss": "^7.0.
|
|
51
|
+
"postcss": "^7.0.32",
|
|
52
52
|
"postcss-modules-extract-imports": "^2.0.0",
|
|
53
53
|
"postcss-modules-local-by-default": "^3.0.2",
|
|
54
54
|
"postcss-modules-scope": "^2.2.0",
|
|
55
55
|
"postcss-modules-values": "^3.0.0",
|
|
56
|
-
"postcss-value-parser": "^4.0
|
|
57
|
-
"schema-utils": "^2.
|
|
56
|
+
"postcss-value-parser": "^4.1.0",
|
|
57
|
+
"schema-utils": "^2.7.0",
|
|
58
58
|
"semver": "^6.3.0"
|
|
59
59
|
},
|
|
60
60
|
"devDependencies": {
|
|
61
|
-
"@babel/cli": "^7.
|
|
62
|
-
"@babel/core": "^7.
|
|
63
|
-
"@babel/preset-env": "^7.
|
|
61
|
+
"@babel/cli": "^7.10.1",
|
|
62
|
+
"@babel/core": "^7.10.2",
|
|
63
|
+
"@babel/preset-env": "^7.10.2",
|
|
64
64
|
"@commitlint/cli": "^8.3.5",
|
|
65
65
|
"@commitlint/config-conventional": "^8.3.4",
|
|
66
66
|
"@webpack-contrib/defaults": "^6.3.0",
|
|
67
67
|
"@webpack-contrib/eslint-config-webpack": "^3.0.0",
|
|
68
|
-
"babel-jest": "^25.
|
|
69
|
-
"commitlint-azure-pipelines-cli": "^1.0.3",
|
|
68
|
+
"babel-jest": "^25.5.1",
|
|
70
69
|
"cross-env": "^7.0.2",
|
|
71
70
|
"del": "^5.1.0",
|
|
72
|
-
"del-cli": "^3.0.
|
|
71
|
+
"del-cli": "^3.0.1",
|
|
73
72
|
"es-check": "^5.1.0",
|
|
74
73
|
"eslint": "^6.8.0",
|
|
75
|
-
"eslint-config-prettier": "^6.
|
|
76
|
-
"eslint-plugin-import": "^2.
|
|
74
|
+
"eslint-config-prettier": "^6.11.0",
|
|
75
|
+
"eslint-plugin-import": "^2.21.2",
|
|
77
76
|
"file-loader": "^6.0.0",
|
|
78
|
-
"husky": "^4.2.
|
|
79
|
-
"jest": "^25.
|
|
80
|
-
"
|
|
81
|
-
"
|
|
82
|
-
"memfs": "^3.1.2",
|
|
77
|
+
"husky": "^4.2.5",
|
|
78
|
+
"jest": "^25.5.4",
|
|
79
|
+
"lint-staged": "^10.2.10",
|
|
80
|
+
"memfs": "^3.2.0",
|
|
83
81
|
"npm-run-all": "^4.1.5",
|
|
84
82
|
"postcss-loader": "^3.0.0",
|
|
85
83
|
"postcss-preset-env": "^6.7.0",
|
|
86
|
-
"prettier": "^2.0.
|
|
87
|
-
"sass": "^1.26.
|
|
84
|
+
"prettier": "^2.0.5",
|
|
85
|
+
"sass": "^1.26.8",
|
|
88
86
|
"sass-loader": "^8.0.2",
|
|
89
|
-
"standard-version": "^
|
|
87
|
+
"standard-version": "^8.0.0",
|
|
90
88
|
"strip-ansi": "^6.0.0",
|
|
91
|
-
"url-loader": "^4.
|
|
92
|
-
"webpack": "^4.
|
|
89
|
+
"url-loader": "^4.1.0",
|
|
90
|
+
"webpack": "^4.43.0"
|
|
93
91
|
},
|
|
94
92
|
"keywords": [
|
|
95
93
|
"webpack",
|