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
+1-1
Original file line number
Diff line number
Diff line change
@@ -7,7 +7,7 @@ All notable changes to this project will be documented in this file. See [standa
7
7
8
8
### Features
9
9
10
-
* allow the `exportLocalsConvention` option can be a function useful for named export ([#1351](https://github.com/webpack-contrib/css-loader/issues/1351)) ([3c4b357](https://github.com/webpack-contrib/css-loader/commit/3c4b35718273baaf9e0480db715b596fbe5d7453))
10
+
* allow the `exportLocalsConvention` option can be a function, useful for named export ([#1351](https://github.com/webpack-contrib/css-loader/issues/1351)) ([3c4b357](https://github.com/webpack-contrib/css-loader/commit/3c4b35718273baaf9e0480db715b596fbe5d7453))
Copy file name to clipboardExpand all lines: README.md
+41-40
Original file line number
Diff line number
Diff line change
@@ -54,48 +54,19 @@ module.exports = {
54
54
55
55
And run `webpack` via your preferred method.
56
56
57
-
### `toString`
58
-
59
-
You can also use the css-loader results directly as a string, such as in Angular's component style.
60
-
61
-
**webpack.config.js**
62
-
63
-
```js
64
-
module.exports= {
65
-
module: {
66
-
rules: [
67
-
{
68
-
test:/\.css$/i,
69
-
use: ["to-string-loader", "css-loader"],
70
-
},
71
-
],
72
-
},
73
-
};
74
-
```
75
-
76
-
or
77
-
78
-
```js
79
-
constcss=require("./test.css").toString();
80
-
81
-
console.log(css); // {String}
82
-
```
83
-
84
-
If there are SourceMaps, they will also be included in the result string.
85
-
86
57
If, for one reason or another, you need to extract CSS as a file (i.e. do not store CSS in a JS module) you might want to check out the [recommend example](https://github.com/webpack-contrib/css-loader#recommend).
|**[`url`](#url)**|`{Boolean\|Object}`|`true`| Allows to enables/disables `url()`/`image-set()` functions handling |
93
-
|**[`import`](#import)**|`{Boolean\|Object}`|`true`| Allows to enables/disables `@import` at-rules handling |
94
-
|**[`modules`](#modules)**|`{Boolean\|String\|Object}`|`{auto: true}`| Allows to enables/disables or setup CSS Modules options |
95
-
|**[`sourceMap`](#sourcemap)**|`{Boolean}`|`compiler.devtool`| Enables/Disables generation of source maps |
96
-
|**[`importLoaders`](#importloaders)**|`{Number}`|`0`| Allows enables/disables or setups number of loaders applied before CSS loader for `@import`/CSS Modules and ICSS imports |
97
-
|**[`esModule`](#esmodule)**|`{Boolean}`|`true`| Use ES modules syntax |
98
-
|**[`exportType`](#exporttype)**|`{'array' \| 'css-style-sheet'}`|`array`| Allows exporting styles as array with modules or [constructable stylesheet](https://developers.google.com/web/updates/2019/02/constructable-stylesheets) (i.e. [`CSSStyleSheet`](https://developer.mozilla.org/en-US/docs/Web/API/CSSStyleSheet)) |
|**[`url`](#url)**|`{Boolean\|Object}`|`true`| Allows to enables/disables `url()`/`image-set()` functions handling|
64
+
|**[`import`](#import)**|`{Boolean\|Object}`|`true`| Allows to enables/disables `@import` at-rules handling|
65
+
|**[`modules`](#modules)**|`{Boolean\|String\|Object}`|`{auto: true}`| Allows to enables/disables or setup CSS Modules options|
66
+
|**[`sourceMap`](#sourcemap)**|`{Boolean}`|`compiler.devtool`| Enables/Disables generation of source maps|
67
+
|**[`importLoaders`](#importloaders)**|`{Number}`|`0`| Allows enables/disables or setups number of loaders applied before CSS loader for `@import`/CSS Modules and ICSS imports|
68
+
|**[`esModule`](#esmodule)**|`{Boolean}`|`true`| Use ES modules syntax|
69
+
|**[`exportType`](#exporttype)**|`{'array' \| 'string' \| 'css-style-sheet'}`|`array`| Allows exporting styles as array with modules, string or [constructable stylesheet](https://developers.google.com/web/updates/2019/02/constructable-stylesheets) (i.e. [`CSSStyleSheet`](https://developer.mozilla.org/en-US/docs/Web/API/CSSStyleSheet)) |
99
70
100
71
### `url`
101
72
@@ -1272,10 +1243,10 @@ module.exports = {
1272
1243
1273
1244
### `exportType`
1274
1245
1275
-
Type: `'array' | 'css-style-sheet'`
1246
+
Type: `'array' | 'string' | 'css-style-sheet'`
1276
1247
Default: `'array'`
1277
1248
1278
-
Allows exporting styles as array with modules or [constructable stylesheet](https://developers.google.com/web/updates/2019/02/constructable-stylesheets) (i.e. [`CSSStyleSheet`](https://developer.mozilla.org/en-US/docs/Web/API/CSSStyleSheet)).
1249
+
Allows exporting styles as array with modules, string or [constructable stylesheet](https://developers.google.com/web/updates/2019/02/constructable-stylesheets) (i.e. [`CSSStyleSheet`](https://developer.mozilla.org/en-US/docs/Web/API/CSSStyleSheet)).
1279
1250
Default value is `'array'`, i.e. loader exports array of modules with specific API which is used in `style-loader` or other.
1280
1251
1281
1252
**webpack.config.js**
@@ -1331,6 +1302,36 @@ module.exports = {
1331
1302
import"./styles.css";
1332
1303
```
1333
1304
1305
+
#### `'string'`
1306
+
1307
+
> ⚠ You don't need [`style-loader`](https://github.com/webpack-contrib/style-loader) anymore, please remove it.
1308
+
> ⚠ The `esModules` option should be enabled if you want to use it with [`CSS modules`](https://github.com/webpack-contrib/css-loader#modules), by default for locals will be used [named export](https://github.com/webpack-contrib/css-loader#namedexport).
0 commit comments