You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardexpand all lines: CHANGELOG.md
+9-3
Original file line number
Diff line number
Diff line change
@@ -8,27 +8,33 @@ All notable changes to this project will be documented in this file. See [standa
8
8
### ⚠ BREAKING CHANGES
9
9
10
10
* minimum supported `Node.js` version is `12.13.0`
11
-
* minimum supported `weboack` version is `5`
11
+
* minimum supported `webpack` version is `5`, we recommend to update to the latest version for better performance
12
12
* for `url` and `import` options `Function` type was removed in favor `Object` type with the `filter` property, i.e. before `{ url: () => true }`, now `{ url: { filter: () => true } }` and before `{ import: () => true }`, now `{ import: { filter: () => true } }`
13
-
* the `importLoaders` option was removed in favor in favor `import.loaders` option
14
13
* the `modules.compileType` option was removed in favor the `modules.mode` option with `icss` value, also the `modules` option can have `icss` string value
15
14
*`new URL()` syntax used for `url()`, only when the `esModules` option is enabled (enabled by default), it means you can bundle CSS for libraries
16
15
*[data URI](https://developer.mozilla.org/en-US/docs/Web/HTTP/Basics_of_HTTP/Data_URIs) are handling in `url()`, it means you can register loaders for them, [example](https://webpack.js.org/configuration/module/#rulescheme)
17
16
* aliases with `false` value for `url()` now generate empty data URI (i.e. `data:0,`), only when the `esModules` option is enabled (enabled by default)
18
-
* using `~` is deprecated when the `esModules` option is enabled (enabled by default) and can be removed from your code (**we recommend it**), but we still support it for historical reasons. Why you can removed it? The loader will first try to resolve `@import`/`url()` as relative, if it cannot be resolved, the loader will try to resolve `@import`/`url()` inside [`node_modules` or modules directories](https://webpack.js.org/configuration/resolve/#resolvemodules).
17
+
* using `~` is deprecated when the `esModules` option is enabled (enabled by default) and can be removed from your code (**we recommend it**) (`url(~package/image.png)` -> `url(package/image.png)`, `@import url(~package/style.css)` -> `@import url(package/style.css)`, `composes: import from '~package/one.css';` -> `composes: import from 'package/one.css';`), but we still support it for historical reasons. Why you can removed it? The loader will first try to resolve `@import`/`url()`/etc as relative, if it cannot be resolved, the loader will try to resolve `@import`/`url()`/etc inside [`node_modules` or modules directories](https://webpack.js.org/configuration/resolve/#resolvemodules).
19
18
*`[ext]` placeholder don't need `.` (dot) before for the `localIdentName` option, i.e. please change `.[ext]` on `[ext]` (no dot before)
20
19
*`[folder]` placeholder was removed without replacement for the `localIdentName` option, please use a custom function if you need complex logic
21
20
*`[emoji]` placeholder was removed without replacement for the `localIdentName` option, please use a custom function if you need complex logic
22
21
* the `localIdentHashPrefix` was removed in favor the `localIdentHashSalt` option
23
22
24
23
### Features
25
24
25
+
* supported [`resolve.byDependency.css`](https://webpack.js.org/configuration/resolve/#resolvebydependency) resolve options for `@import`
* added `modules.localIdentHashFunction`, `modules.localIdentHashDigest`, `modules.localIdentHashDigestLength` options for better class hashing controlling
27
28
* less dependencies
28
29
29
30
### Bug Fixes
30
31
31
32
* better performance
33
+
* fixed circular `@import`
34
+
35
+
### Notes
36
+
37
+
***we strongly recommend not to add `.css` to `resolve.extensions`, it reduces performance and in most cases it is simply not necessary, alternative you can set resolve options [by dependency](https://webpack.js.org/configuration/resolve/#resolvebydependency)**
|**[`url`](#url)**|`{Boolean\|Object}`|`true`| Allows to enables/disables `url()`/`image-set()` functions handling |
115
+
|**[`import`](#import)**|`{Boolean\|Object}`|`true`| Allows to enables/disables `@import` at-rules handling |
116
+
|**[`modules`](#modules)**|`{Boolean\|String\|Object}`|`{auto: true}`| Allows to enables/disables or setup CSS Modules options |
117
+
|**[`sourceMap`](#sourcemap)**|`{Boolean}`|`compiler.devtool`| Enables/Disables generation of source maps |
118
+
|**[`importLoaders`](#importloaders)**|`{Number}`|`0`| Allows enables/disables or setups number of loaders applied before CSS loader for `@import`/CSS Modules and ICSS imports |
119
+
|**[`esModule`](#esmodule)**|`{Boolean}`|`true`| Use ES modules syntax |
|**[`filter`](#filter)**|`{Function}`|`undefined`| Allow to filter `@import`|
260
260
261
261
##### `filter`
262
262
@@ -294,47 +294,6 @@ module.exports = {
294
294
};
295
295
```
296
296
297
-
##### `loaders`
298
-
299
-
Type: `Number`
300
-
Default: `0`
301
-
302
-
Enables/Disables or setups number of loaders applied before CSS loader.
303
-
304
-
The option `import.loaders` allows you to configure how many loaders before `css-loader` should be applied to `@import`ed resources.
305
-
306
-
**webpack.config.js**
307
-
308
-
```js
309
-
module.exports= {
310
-
module: {
311
-
rules: [
312
-
{
313
-
test:/\.css$/i,
314
-
use: [
315
-
"style-loader",
316
-
{
317
-
loader:"css-loader",
318
-
options: {
319
-
import: {
320
-
loaders:2,
321
-
// 0 => no loaders (default);
322
-
// 1 => postcss-loader;
323
-
// 2 => postcss-loader, sass-loader
324
-
},
325
-
},
326
-
},
327
-
"postcss-loader",
328
-
"sass-loader",
329
-
],
330
-
},
331
-
],
332
-
},
333
-
};
334
-
```
335
-
336
-
This may change in the future when the module system (i. e. webpack) supports loader matching by origin.
337
-
338
297
### `modules`
339
298
340
299
Type: `Boolean|String|Object`
@@ -1182,6 +1141,45 @@ module.exports = {
1182
1141
};
1183
1142
```
1184
1143
1144
+
### `importLoaders`
1145
+
1146
+
Type: `Number`
1147
+
Default: `0`
1148
+
1149
+
Allows to enables/disables or setups number of loaders applied before CSS loader for `@import` at-rules, CSS modules and ICSS imports, i.e. `@import`/`composes`/`@value value from './values.css'`/etc.
1150
+
1151
+
The option `importLoaders` allows you to configure how many loaders before `css-loader` should be applied to `@import`ed resources and CSS modules/ICSS imports.
1152
+
1153
+
**webpack.config.js**
1154
+
1155
+
```js
1156
+
module.exports= {
1157
+
module: {
1158
+
rules: [
1159
+
{
1160
+
test:/\.css$/i,
1161
+
use: [
1162
+
"style-loader",
1163
+
{
1164
+
loader:"css-loader",
1165
+
options: {
1166
+
importLoaders:2,
1167
+
// 0 => no loaders (default);
1168
+
// 1 => postcss-loader;
1169
+
// 2 => postcss-loader, sass-loader
1170
+
},
1171
+
},
1172
+
"postcss-loader",
1173
+
"sass-loader",
1174
+
],
1175
+
},
1176
+
],
1177
+
},
1178
+
};
1179
+
```
1180
+
1181
+
This may change in the future when the module system (i. e. webpack) supports loader matching by origin.
1182
+
1185
1183
### `sourceMap`
1186
1184
1187
1185
Type: `Boolean`
@@ -1377,7 +1375,7 @@ module.exports = {
1377
1375
{
1378
1376
loader:"css-loader",
1379
1377
options: {
1380
-
// Run `postcss-loader` on each CSS `@import`, do not forget that `sass-loader` compile non CSS `@import`'s into a single file
1378
+
// Run `postcss-loader` on each CSS `@import` and CSS modules/ICSS imports, do not forget that `sass-loader` compile non CSS `@import`'s into a single file
1381
1379
// If you need run `sass-loader` and `postcss-loader` on each CSS `@import` please set it to `2`
Copy file name to clipboardexpand all lines: src/options.json
+15-15
Original file line number
Diff line number
Diff line change
@@ -3,7 +3,7 @@
3
3
"additionalProperties": false,
4
4
"properties": {
5
5
"url": {
6
-
"description": "Allow to enable/disables handling the CSS functions `url` and `image-set` (https://github.com/webpack-contrib/css-loader#url).",
6
+
"description": "Allows to enables/disables `url()`/`image-set()` functions handling (https://github.com/webpack-contrib/css-loader#url).",
7
7
"anyOf": [
8
8
{
9
9
"type": "boolean"
@@ -30,20 +30,6 @@
30
30
"properties": {
31
31
"filter": {
32
32
"instanceof": "Function"
33
-
},
34
-
"loaders": {
35
-
"description": "Enables/Disables or setups number of loaders applied before CSS loader (https://github.com/webpack-contrib/css-loader#importloaders).",
36
-
"anyOf": [
37
-
{
38
-
"type": "boolean"
39
-
},
40
-
{
41
-
"type": "string"
42
-
},
43
-
{
44
-
"type": "integer"
45
-
}
46
-
]
47
33
}
48
34
},
49
35
"additionalProperties": false
@@ -163,6 +149,20 @@
163
149
"description": "Allows to enable/disable source maps (https://github.com/webpack-contrib/css-loader#sourcemap).",
164
150
"type": "boolean"
165
151
},
152
+
"importLoaders": {
153
+
"description": "Allows enables/disables or setups number of loaders applied before CSS loader for `@import`/CSS Modules and ICSS imports (https://github.com/webpack-contrib/css-loader#importloaders).",
154
+
"anyOf": [
155
+
{
156
+
"type": "boolean"
157
+
},
158
+
{
159
+
"type": "string"
160
+
},
161
+
{
162
+
"type": "integer"
163
+
}
164
+
]
165
+
},
166
166
"esModule": {
167
167
"description": "Use the ES modules syntax (https://github.com/webpack-contrib/css-loader#esmodule).",
0 commit comments