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: src/content/plugins/mini-css-extract-plugin.mdx
+161-9Lines changed: 161 additions & 9 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -78,19 +78,23 @@ module.exports = {
78
78
};
79
79
```
80
80
81
+
> ⚠️ Note that if you import CSS from your webpack entrypoint or import styles in the [initial](/concepts/under-the-hood/#chunks) chunk, `mini-css-extract-plugin` will not load this CSS into the page. Please use [`html-webpack-plugin`](https://github.com/jantimon/html-webpack-plugin) for automatic generation `link` tags or create `index.html` file with `link` tag.
82
+
83
+
> ⚠️ Source maps works only for `source-map`/`nosources-source-map`/`hidden-nosources-source-map`/`hidden-source-map` values because CSS only supports source maps with the `sourceMappingURL` comment (i.e. `//# sourceMappingURL=style.css.map`). If you need set `devtool` to another value you can enable source maps generation for extracted CSS using [`sourceMap: true`](https://github.com/webpack-contrib/css-loader#sourcemap) for `css-loader`.
|**[`filename`](#filename)**|`{String\|Function}`|`[name].css`| This option determines the name of each output CSS file |
88
-
|**[`chunkFilename`](#chunkfilename)**|`{String\|Function}`|`based on filename`| This option determines the name of non-entry chunk files |
89
-
|**[`ignoreOrder`](#ignoreorder)**|`{Boolean}`|`false`| Remove Order Warnings |
90
-
|**[`insert`](#insert)**|`{String\|Function}`|`document.head.appendChild(linkTag);`| Inserts `<link>`at the given position |
91
-
|**[`attributes`](#attributes)**|`{Object}`|`{}`| Adds custom attributes to tag |
92
-
|**[`linkType`](#linktype)**|`{String\|Boolean}`|`text/css`| Allows loading asynchronous chunks with a custom link type |
93
-
|**[`experimentalUseImportModule`](#experimentaluseimportmodule)**|`{Boolean}`|`false`| Use an experimental webpack API to execute modules instead of child compilers |
|**[`filename`](#filename)**|`{String\|Function}`|`[name].css`| This option determines the name of each output CSS file |
92
+
|**[`chunkFilename`](#chunkfilename)**|`{String\|Function}`|`based on filename`| This option determines the name of non-entry chunk files |
93
+
|**[`ignoreOrder`](#ignoreorder)**|`{Boolean}`|`false`| Remove Order Warnings |
94
+
|**[`insert`](#insert)**|`{String\|Function}`|`document.head.appendChild(linkTag);`| Inserts the `link` tag at the given position for [non-initial (async)](/concepts/under-the-hood/#chunks) CSS chunks|
95
+
|**[`attributes`](#attributes)**|`{Object}`|`{}`| Adds custom attributes to the `link` tag for [non-initial (async)](/concepts/under-the-hood/#chunks) CSS chunks|
96
+
|**[`linkType`](#linktype)**|`{String\|Boolean}`|`text/css`| Allows loading asynchronous chunks with a custom link type |
97
+
|**[`experimentalUseImportModule`](#experimentaluseimportmodule)**|`{Boolean}`|`false`| Use an experimental webpack API to execute modules instead of child compilers |
94
98
95
99
#### `filename`
96
100
@@ -125,6 +129,8 @@ See [examples](#remove-order-warnings) below for details.
125
129
Type: `String|Function`
126
130
Default: `document.head.appendChild(linkTag);`
127
131
132
+
> ⚠️ Only for [non-initial (async)](/concepts/under-the-hood/#chunks) chunks.
133
+
128
134
By default, the `mini-css-extract-plugin` appends styles (`<link>` elements) to `document.head` of the current `window`.
129
135
130
136
However in some circumstances it might be necessary to have finer control over the append target or even delay `link` elements insertion.
@@ -176,6 +182,8 @@ A new `<link>` element will be inserted before the element with id `some-element
176
182
Type: `Object`
177
183
Default: `{}`
178
184
185
+
> ⚠️ Only for [non-initial (async)](/concepts/under-the-hood/#chunks) chunks.
186
+
179
187
If defined, the `mini-css-extract-plugin` will attach given attributes with their values on `<link>` element.
If you'd like to extract the media queries from the extracted CSS (so mobile users don't need to load desktop or tablet specific CSS anymore) you should use one of the following plugins:
0 commit comments