css-loader 4.1.1 → 4.2.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 +7 -0
- package/README.md +41 -36
- package/dist/index.js +2 -3
- package/dist/options.json +4 -0
- package/dist/utils.js +13 -2
- package/package.json +1 -1
package/CHANGELOG.md
CHANGED
|
@@ -2,6 +2,13 @@
|
|
|
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
|
+
## [4.2.0](https://github.com/webpack-contrib/css-loader/compare/v4.1.1...v4.2.0) (2020-07-31)
|
|
6
|
+
|
|
7
|
+
|
|
8
|
+
### Features
|
|
9
|
+
|
|
10
|
+
* add `module.type` option, the `icss` option is deprecated ([#1150](https://github.com/webpack-contrib/css-loader/issues/1150)) ([68f72af](https://github.com/webpack-contrib/css-loader/commit/68f72af2a09111f74dcacbf7af019fe7eb40cb6c))
|
|
11
|
+
|
|
5
12
|
### [4.1.1](https://github.com/webpack-contrib/css-loader/compare/v4.1.0...v4.1.1) (2020-07-30)
|
|
6
13
|
|
|
7
14
|
|
package/README.md
CHANGED
|
@@ -109,15 +109,14 @@ module.exports = {
|
|
|
109
109
|
|
|
110
110
|
## Options
|
|
111
111
|
|
|
112
|
-
| Name | Type |
|
|
113
|
-
| :-----------------------------------: | :-------------------------: |
|
|
114
|
-
| **[`url`](#url)** | `{Boolean\|Function}` |
|
|
115
|
-
| **[`import`](#import)** | `{Boolean\|Function}` |
|
|
116
|
-
| **[`modules`](#modules)** | `{Boolean\|String\|Object}` |
|
|
117
|
-
|
|
|
118
|
-
|
|
|
119
|
-
|
|
|
120
|
-
| **[`esModule`](#esmodule)** | `{Boolean}` | `true` | Use ES modules syntax |
|
|
112
|
+
| Name | Type | Default | Description |
|
|
113
|
+
| :-----------------------------------: | :-------------------------: | :----------------: | :--------------------------------------------------------------------- |
|
|
114
|
+
| **[`url`](#url)** | `{Boolean\|Function}` | `true` | Enables/Disables `url`/`image-set` functions handling |
|
|
115
|
+
| **[`import`](#import)** | `{Boolean\|Function}` | `true` | Enables/Disables `@import` at-rules handling |
|
|
116
|
+
| **[`modules`](#modules)** | `{Boolean\|String\|Object}` | `{auto: true}` | Enables/Disables CSS Modules and their configuration |
|
|
117
|
+
| **[`sourceMap`](#sourcemap)** | `{Boolean}` | `compiler.devtool` | Enables/Disables generation of source maps |
|
|
118
|
+
| **[`importLoaders`](#importloaders)** | `{Number}` | `0` | Enables/Disables or setups number of loaders applied before CSS loader |
|
|
119
|
+
| **[`esModule`](#esmodule)** | `{Boolean}` | `true` | Use ES modules syntax |
|
|
121
120
|
|
|
122
121
|
### `url`
|
|
123
122
|
|
|
@@ -526,6 +525,7 @@ module.exports = {
|
|
|
526
525
|
loader: 'css-loader',
|
|
527
526
|
options: {
|
|
528
527
|
modules: {
|
|
528
|
+
compileType: 'module',
|
|
529
529
|
mode: 'local',
|
|
530
530
|
auto: true,
|
|
531
531
|
exportGlobals: true,
|
|
@@ -543,6 +543,38 @@ module.exports = {
|
|
|
543
543
|
};
|
|
544
544
|
```
|
|
545
545
|
|
|
546
|
+
##### `compileType`
|
|
547
|
+
|
|
548
|
+
Type: `'module' | 'icss'`
|
|
549
|
+
Default: `'module'`
|
|
550
|
+
|
|
551
|
+
Controls the level of compilation applied to the input styles.
|
|
552
|
+
|
|
553
|
+
The `module` handles `class` and `id` scoping and `@value` values.
|
|
554
|
+
The `icss` will only compile the low level `Interoperable CSS` format for declaring `:import` and `:export` dependencies between CSS and other languages.
|
|
555
|
+
|
|
556
|
+
ICSS underpins CSS Module support, and provides a low level syntax for other tools to implement CSS-module variations of their own.
|
|
557
|
+
|
|
558
|
+
**webpack.config.js**
|
|
559
|
+
|
|
560
|
+
```js
|
|
561
|
+
module.exports = {
|
|
562
|
+
module: {
|
|
563
|
+
rules: [
|
|
564
|
+
{
|
|
565
|
+
test: /\.css$/i,
|
|
566
|
+
loader: 'css-loader',
|
|
567
|
+
options: {
|
|
568
|
+
modules: {
|
|
569
|
+
compileType: 'icss',
|
|
570
|
+
},
|
|
571
|
+
},
|
|
572
|
+
},
|
|
573
|
+
],
|
|
574
|
+
},
|
|
575
|
+
};
|
|
576
|
+
```
|
|
577
|
+
|
|
546
578
|
##### `auto`
|
|
547
579
|
|
|
548
580
|
Type: `Boolean|RegExp|Function`
|
|
@@ -1001,33 +1033,6 @@ module.exports = {
|
|
|
1001
1033
|
};
|
|
1002
1034
|
```
|
|
1003
1035
|
|
|
1004
|
-
### `icss`
|
|
1005
|
-
|
|
1006
|
-
Type: Boolean Default: `true` if `modules` are enabled, false otherwise
|
|
1007
|
-
|
|
1008
|
-
Enables/disables handling of the low level "Interoperable CSS" format for declaring
|
|
1009
|
-
import and export dependencies between CSS and other languages. ICSS enables
|
|
1010
|
-
CSS Module support, and is enabled automatically when `modules` are enabled. It
|
|
1011
|
-
can also be enabled independently to allow other loaders to handle processing CSS modules.
|
|
1012
|
-
|
|
1013
|
-
**webpack.config.js**
|
|
1014
|
-
|
|
1015
|
-
```js
|
|
1016
|
-
module.exports = {
|
|
1017
|
-
module: {
|
|
1018
|
-
rules: [
|
|
1019
|
-
{
|
|
1020
|
-
test: /\.css$/i,
|
|
1021
|
-
loader: 'css-loader',
|
|
1022
|
-
options: {
|
|
1023
|
-
icss: true,
|
|
1024
|
-
},
|
|
1025
|
-
},
|
|
1026
|
-
],
|
|
1027
|
-
},
|
|
1028
|
-
};
|
|
1029
|
-
```
|
|
1030
|
-
|
|
1031
1036
|
### `sourceMap`
|
|
1032
1037
|
|
|
1033
1038
|
Type: `Boolean`
|
package/dist/index.js
CHANGED
|
@@ -50,9 +50,8 @@ async function loader(content, map, meta) {
|
|
|
50
50
|
|
|
51
51
|
const replacements = [];
|
|
52
52
|
const exports = [];
|
|
53
|
-
const needUseModulesPlugins = (0, _utils.shouldUseModulesPlugins)(options);
|
|
54
53
|
|
|
55
|
-
if (
|
|
54
|
+
if ((0, _utils.shouldUseModulesPlugins)(options)) {
|
|
56
55
|
plugins.push(...(0, _utils.getModulesPlugins)(options, this));
|
|
57
56
|
}
|
|
58
57
|
|
|
@@ -101,7 +100,7 @@ async function loader(content, map, meta) {
|
|
|
101
100
|
const icssPluginImports = [];
|
|
102
101
|
const icssPluginApi = [];
|
|
103
102
|
|
|
104
|
-
if (
|
|
103
|
+
if ((0, _utils.shouldUseIcssPlugin)(options)) {
|
|
105
104
|
const icssResolver = this.getResolve({
|
|
106
105
|
conditionNames: ['style'],
|
|
107
106
|
extensions: [],
|
package/dist/options.json
CHANGED
|
@@ -36,6 +36,10 @@
|
|
|
36
36
|
"type": "object",
|
|
37
37
|
"additionalProperties": false,
|
|
38
38
|
"properties": {
|
|
39
|
+
"compileType": {
|
|
40
|
+
"description": "Controls the extent to which css-loader will process module code (https://github.com/webpack-contrib/css-loader#type)",
|
|
41
|
+
"enum": ["module", "icss"]
|
|
42
|
+
},
|
|
39
43
|
"auto": {
|
|
40
44
|
"description": "Allows auto enable CSS modules based on filename (https://github.com/webpack-contrib/css-loader#auto).",
|
|
41
45
|
"anyOf": [
|
package/dist/utils.js
CHANGED
|
@@ -7,6 +7,7 @@ exports.normalizeOptions = normalizeOptions;
|
|
|
7
7
|
exports.shouldUseModulesPlugins = shouldUseModulesPlugins;
|
|
8
8
|
exports.shouldUseImportPlugin = shouldUseImportPlugin;
|
|
9
9
|
exports.shouldUseURLPlugin = shouldUseURLPlugin;
|
|
10
|
+
exports.shouldUseIcssPlugin = shouldUseIcssPlugin;
|
|
10
11
|
exports.normalizeUrl = normalizeUrl;
|
|
11
12
|
exports.requestify = requestify;
|
|
12
13
|
exports.getFilter = getFilter;
|
|
@@ -141,6 +142,7 @@ function getModulesOptions(rawOptions, loaderContext) {
|
|
|
141
142
|
}
|
|
142
143
|
|
|
143
144
|
let modulesOptions = {
|
|
145
|
+
compileType: rawOptions.icss ? 'icss' : 'module',
|
|
144
146
|
auto: true,
|
|
145
147
|
mode: 'local',
|
|
146
148
|
exportGlobals: false,
|
|
@@ -207,12 +209,17 @@ function getModulesOptions(rawOptions, loaderContext) {
|
|
|
207
209
|
}
|
|
208
210
|
|
|
209
211
|
function normalizeOptions(rawOptions, loaderContext) {
|
|
212
|
+
if (rawOptions.icss) {
|
|
213
|
+
loaderContext.emitWarning(new Error('The "icss" option is deprecated, use "modules.compileType: "icss"" instead'));
|
|
214
|
+
}
|
|
215
|
+
|
|
210
216
|
const modulesOptions = getModulesOptions(rawOptions, loaderContext);
|
|
211
217
|
return {
|
|
212
218
|
url: typeof rawOptions.url === 'undefined' ? true : rawOptions.url,
|
|
213
219
|
import: typeof rawOptions.import === 'undefined' ? true : rawOptions.import,
|
|
214
220
|
modules: modulesOptions,
|
|
215
|
-
|
|
221
|
+
// TODO remove in the next major release
|
|
222
|
+
icss: typeof rawOptions.icss === 'undefined' ? false : rawOptions.icss,
|
|
216
223
|
sourceMap: typeof rawOptions.sourceMap === 'boolean' ? rawOptions.sourceMap : loaderContext.sourceMap,
|
|
217
224
|
importLoaders: rawOptions.importLoaders,
|
|
218
225
|
esModule: typeof rawOptions.esModule === 'undefined' ? true : rawOptions.esModule
|
|
@@ -244,7 +251,11 @@ function shouldUseURLPlugin(options) {
|
|
|
244
251
|
}
|
|
245
252
|
|
|
246
253
|
function shouldUseModulesPlugins(options) {
|
|
247
|
-
return
|
|
254
|
+
return options.modules.compileType === 'module';
|
|
255
|
+
}
|
|
256
|
+
|
|
257
|
+
function shouldUseIcssPlugin(options) {
|
|
258
|
+
return options.icss === true || Boolean(options.modules);
|
|
248
259
|
}
|
|
249
260
|
|
|
250
261
|
function getModulesPlugins(options, loaderContext) {
|