Skip to content

Commit 34b65ac

Browse files
fix: better description for async chunk options
1 parent 885e739 commit 34b65ac

File tree

3 files changed

+21
-15
lines changed

3 files changed

+21
-15
lines changed

README.md

+15-9
Original file line numberDiff line numberDiff line change
@@ -71,19 +71,21 @@ module.exports = {
7171
};
7272
```
7373

74+
> ⚠️ Note that if you import CSS from your webpack entrypoint or import styles in the [initial](https://webpack.js.org/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.
75+
7476
## Options
7577

7678
### Plugin Options
7779

78-
| Name | Type | Default | Description |
79-
| :---------------------------------------------------------------: | :------------------: | :-----------------------------------: | :---------------------------------------------------------------------------- |
80-
| **[`filename`](#filename)** | `{String\|Function}` | `[name].css` | This option determines the name of each output CSS file |
81-
| **[`chunkFilename`](#chunkFilename)** | `{String\|Function}` | `based on filename` | This option determines the name of non-entry chunk files |
82-
| **[`ignoreOrder`](#ignoreOrder)** | `{Boolean}` | `false` | Remove Order Warnings |
83-
| **[`insert`](#insert)** | `{String\|Function}` | `document.head.appendChild(linkTag);` | Inserts `<link>` at the given position |
84-
| **[`attributes`](#attributes)** | `{Object}` | `{}` | Adds custom attributes to tag |
85-
| **[`linkType`](#linkType)** | `{String\|Boolean}` | `text/css` | Allows loading asynchronous chunks with a custom link type |
86-
| **[`experimentalUseImportModule`](#experimentalUseImportModule)** | `{Boolean}` | `false` | Use an experimental webpack API to execute modules instead of child compilers |
80+
| Name | Type | Default | Description |
81+
| :---------------------------------------------------------------: | :------------------: | :-----------------------------------: | :---------------------------------------------------------------------------------------------------------------------------------------- |
82+
| **[`filename`](#filename)** | `{String\|Function}` | `[name].css` | This option determines the name of each output CSS file |
83+
| **[`chunkFilename`](#chunkFilename)** | `{String\|Function}` | `based on filename` | This option determines the name of non-entry chunk files |
84+
| **[`ignoreOrder`](#ignoreOrder)** | `{Boolean}` | `false` | Remove Order Warnings |
85+
| **[`insert`](#insert)** | `{String\|Function}` | `document.head.appendChild(linkTag);` | Inserts the `link` tag at the given position for [non-initial (async)](https://webpack.js.org/concepts/under-the-hood/#chunks) CSS chunks |
86+
| **[`attributes`](#attributes)** | `{Object}` | `{}` | Adds custom attributes to the `link` tag for [non-initial (async)](https://webpack.js.org/concepts/under-the-hood/#chunks) CSS chunks |
87+
| **[`linkType`](#linkType)** | `{String\|Boolean}` | `text/css` | Allows loading asynchronous chunks with a custom link type |
88+
| **[`experimentalUseImportModule`](#experimentalUseImportModule)** | `{Boolean}` | `false` | Use an experimental webpack API to execute modules instead of child compilers |
8789

8890
#### `filename`
8991

@@ -118,6 +120,8 @@ See [examples](#remove-order-warnings) below for details.
118120
Type: `String|Function`
119121
Default: `document.head.appendChild(linkTag);`
120122

123+
> ⚠️ Only for [non-initial (async)](https://webpack.js.org/concepts/under-the-hood/#chunks) chunks.
124+
121125
By default, the `mini-css-extract-plugin` appends styles (`<link>` elements) to `document.head` of the current `window`.
122126

123127
However in some circumstances it might be necessary to have finer control over the append target or even delay `link` elements insertion.
@@ -169,6 +173,8 @@ A new `<link>` element will be inserted before the element with id `some-element
169173
Type: `Object`
170174
Default: `{}`
171175

176+
> ⚠️ Only for [non-initial (async)](https://webpack.js.org/concepts/under-the-hood/#chunks) chunks.
177+
172178
If defined, the `mini-css-extract-plugin` will attach given attributes with their values on `<link>` element.
173179

174180
**webpack.config.js**

src/plugin-options.json

+2-2
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@
3838
"link": "https://github.com/webpack-contrib/mini-css-extract-plugin#ignoreorder"
3939
},
4040
"insert": {
41-
"description": "Inserts `<link>` at the given position.",
41+
"description": "Inserts the `link` tag at the given position for non-initial (async) (https://webpack.js.org/concepts/under-the-hood/#chunks) CSS chunks.",
4242
"link": "https://github.com/webpack-contrib/mini-css-extract-plugin#insert",
4343
"anyOf": [
4444
{
@@ -50,7 +50,7 @@
5050
]
5151
},
5252
"attributes": {
53-
"description": "Adds custom attributes to tag.",
53+
"description": "Adds custom attributes to the `link` tag for non-initial (async) (https://webpack.js.org/concepts/under-the-hood/#chunks) CSS chunks.",
5454
"link": "https://github.com/webpack-contrib/mini-css-extract-plugin#attributes",
5555
"type": "object"
5656
},

test/__snapshots__/validate-plugin-options.test.js.snap

+4-4
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ exports[`validate options should throw an error on the "attributes" option with
44
"Invalid options object. Mini CSS Extract Plugin has been initialized using an options object that does not match the API schema.
55
- options.attributes should be an object:
66
object {}
7-
-> Adds custom attributes to tag.
7+
-> Adds custom attributes to the \`link\` tag for non-initial (async) (https://webpack.js.org/concepts/under-the-hood/#chunks) CSS chunks.
88
-> Read more at https://github.com/webpack-contrib/mini-css-extract-plugin#attributes"
99
`;
1010

@@ -41,7 +41,7 @@ exports[`validate options should throw an error on the "insert" option with "{}"
4141
"Invalid options object. Mini CSS Extract Plugin has been initialized using an options object that does not match the API schema.
4242
- options.insert should be one of these:
4343
string | function
44-
-> Inserts \`<link>\` at the given position.
44+
-> Inserts the \`link\` tag at the given position for non-initial (async) (https://webpack.js.org/concepts/under-the-hood/#chunks) CSS chunks.
4545
-> Read more at https://github.com/webpack-contrib/mini-css-extract-plugin#insert
4646
Details:
4747
* options.insert should be a string.
@@ -52,7 +52,7 @@ exports[`validate options should throw an error on the "insert" option with "1"
5252
"Invalid options object. Mini CSS Extract Plugin has been initialized using an options object that does not match the API schema.
5353
- options.insert should be one of these:
5454
string | function
55-
-> Inserts \`<link>\` at the given position.
55+
-> Inserts the \`link\` tag at the given position for non-initial (async) (https://webpack.js.org/concepts/under-the-hood/#chunks) CSS chunks.
5656
-> Read more at https://github.com/webpack-contrib/mini-css-extract-plugin#insert
5757
Details:
5858
* options.insert should be a string.
@@ -63,7 +63,7 @@ exports[`validate options should throw an error on the "insert" option with "tru
6363
"Invalid options object. Mini CSS Extract Plugin has been initialized using an options object that does not match the API schema.
6464
- options.insert should be one of these:
6565
string | function
66-
-> Inserts \`<link>\` at the given position.
66+
-> Inserts the \`link\` tag at the given position for non-initial (async) (https://webpack.js.org/concepts/under-the-hood/#chunks) CSS chunks.
6767
-> Read more at https://github.com/webpack-contrib/mini-css-extract-plugin#insert
6868
Details:
6969
* options.insert should be a string.

0 commit comments

Comments
 (0)