Skip to content

Commit ead700f

Browse files
authored
docs: fix typos and improve clarity in docs (#642)
1 parent adbd42b commit ead700f

File tree

1 file changed

+51
-40
lines changed

1 file changed

+51
-40
lines changed

README.md

Lines changed: 51 additions & 40 deletions
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,7 @@ pnpm add -D style-loader
3939

4040
It's recommended to combine `style-loader` with the [`css-loader`](https://github.com/webpack-contrib/css-loader)
4141

42-
Then add the loader to your `webpack` config. For example:
42+
Then add the loader to your `webpack` configuration. For example:
4343

4444
**style.css**
4545

@@ -100,13 +100,13 @@ type injectType =
100100

101101
Default: `styleTag`
102102

103-
Allows to setup how styles will be injected into the DOM.
103+
Allows you to setup how styles will be injected into the DOM.
104104

105105
Possible values:
106106

107107
#### `styleTag`
108108

109-
Automatically injects styles into the DOM using multiple `<style></style>`. It is **default** behaviour.
109+
Automatically injects styles into the DOM using multiple `<style></style>`. It is the **default** behaviour.
110110

111111
**component.js**
112112

@@ -125,7 +125,7 @@ const divElement = document.createElement("div");
125125
divElement.className = styles["my-class"];
126126
```
127127

128-
All local variables (class names) are exported as named exports. To achieve this behaviour you also have to setup `modules` option for `css-loader`. For more information consult with `css-loader` [`documentation`](https://github.com/webpack-contrib/css-loader).
128+
All local variables (class names) are exported as named exports. To achieve this behaviour you also have to set up the `modules` option for `css-loader`. For more information, consult the `css-loader` [`documentation`](https://github.com/webpack-contrib/css-loader).
129129

130130
**webpack.config.js**
131131

@@ -167,7 +167,7 @@ The loader inject styles like:
167167

168168
#### `singletonStyleTag`
169169

170-
Automatically injects styles into the DOM using one `<style></style>`.
170+
Automatically injects styles into the DOM using a single `<style></style>` tag.
171171

172172
> [!WARNING]
173173
>
@@ -188,7 +188,7 @@ const divElement = document.createElement("div");
188188
divElement.className = styles["my-class"];
189189
```
190190

191-
All local variables (class names) are exported as named exports. To achieve this behaviour you also have to setup `modules` option for `css-loader`. For more information consult with `css-loader` [`documentation`](https://github.com/webpack-contrib/css-loader).
191+
All local variables (class names) are exported as named exports. To achieve this behaviour, you also have to set up the `modules` option for `css-loader`. For more information, consult the `css-loader` [`documentation`](https://github.com/webpack-contrib/css-loader).
192192

193193
**webpack.config.js**
194194

@@ -234,9 +234,11 @@ Works the same as a [`styleTag`](#styleTag), but if the code is executed in IE6-
234234

235235
#### `lazyStyleTag`
236236

237-
Injects styles into the DOM using multiple `<style></style>` on demand.
238-
We recommend following `.lazy.css` naming convention for lazy styles and the `.css` for basic `style-loader` usage (similar to other file types, i.e. `.lazy.less` and `.less`).
239-
When you `lazyStyleTag` value the `style-loader` injects the styles lazily making them useable on-demand via `style.use()` / `style.unuse()`.
237+
Injects styles into the DOM using multiple `<style></style>` tags on demand.
238+
239+
We recommend following the `.lazy.css` naming convention for lazy styles and `.css` for basic `style-loader` usage (similar to other file types, i.e. `.lazy.less` and `.less`).
240+
241+
When you use the `lazyStyleTag` value, `style-loader` injects the styles lazily, making them useable on-demand via `style.use()` / `style.unuse()`.
240242

241243
> ⚠️ Behavior is undefined when `unuse` is called more often than `use`. Don't do that.
242244
@@ -261,7 +263,7 @@ const divElement = document.createElement("div");
261263
divElement.className = myClass;
262264
```
263265

264-
All local variables (class names) are exported as named exports. To achieve this behaviour you also have to setup `modules` option for `css-loader`. For more information consult with `css-loader` [`documentation`](https://github.com/webpack-contrib/css-loader).
266+
All local variables (class names) are exported as named exports. To achieve this behaviour, you also have to set up the `modules` option for `css-loader`. For more information, consult the `css-loader` [`documentation`](https://github.com/webpack-contrib/css-loader).
265267

266268
**webpack.config.js**
267269

@@ -307,9 +309,11 @@ The loader inject styles like:
307309

308310
#### `lazySingletonStyleTag`
309311

310-
Injects styles into the DOM using one `<style></style>` on demand.
312+
Injects styles into the DOM using a single `<style></style>` tag on demand.
313+
311314
We recommend following `.lazy.css` naming convention for lazy styles and the `.css` for basic `style-loader` usage (similar to other file types, i.e. `.lazy.less` and `.less`).
312-
When you `lazySingletonStyleTag` value the `style-loader` injects the styles lazily making them useable on-demand via `style.use()` / `style.unuse()`.
315+
316+
When you use the `lazySingletonStyleTag` value, `style-loader` injects the styles lazily making them useable on-demand via `style.use()` / `style.unuse()`.
313317

314318
> ⚠️ Source maps do not work.
315319
@@ -336,7 +340,7 @@ const divElement = document.createElement("div");
336340
divElement.className = myClass;
337341
```
338342

339-
All local variables (class names) are exported as named exports. To achieve this behaviour you also have to setup `modules` option for `css-loader`. For more information consult with `css-loader` [`documentation`](https://github.com/webpack-contrib/css-loader).
343+
All local variables (class names) are exported as named exports. To achieve this behaviour, you also have to set up the `modules` option for `css-loader`. For more information, consult the `css-loader` [`documentation`](https://github.com/webpack-contrib/css-loader).
340344

341345
**webpack.config.js**
342346

@@ -431,7 +435,7 @@ type attributes = HTMLAttributes;
431435

432436
Default: `{}`
433437

434-
If defined, the `style-loader` will attach given attributes with their values on `<style>` / `<link>` element.
438+
If defined, the `style-loader` will attach the given attributes with their values on `<style>` / `<link>` element.
435439

436440
**component.js**
437441

@@ -472,13 +476,16 @@ type insert = string;
472476
Default: `head`
473477

474478
By default, the `style-loader` appends `<style>`/`<link>` elements to the end of the style target, which is the `<head>` tag of the page unless specified by `insert`.
479+
475480
This will cause CSS created by the loader to take priority over CSS already present in the target.
481+
476482
You can use other values if the standard behavior is not suitable for you, but we do not recommend doing this.
477-
If you target an [iframe](https://developer.mozilla.org/en-US/docs/Web/API/HTMLIFrameElement) make sure you have sufficient access rights, the styles will be injected into the content document head.
483+
484+
If you target an [iframe](https://developer.mozilla.org/en-US/docs/Web/API/HTMLIFrameElement), make sure you have sufficient access rights; the styles will be injected into the content document head.
478485

479486
#### `Selector`
480487

481-
Allows to setup custom [query selector](https://developer.mozilla.org/en-US/docs/Web/API/Document/querySelector) where styles inject into the DOM.
488+
Allows you to setup custom [query selector](https://developer.mozilla.org/en-US/docs/Web/API/Document/querySelector) where styles are injected into the DOM.
482489

483490
**webpack.config.js**
484491

@@ -505,15 +512,15 @@ module.exports = {
505512

506513
#### `Absolute path to function`
507514

508-
Allows to setup absolute path to custom function that allows to override default behavior and insert styles at any position.
515+
Allows you to setup an absolute path to custom function that allows to override the default behavior and insert styles at any position.
509516

510517
> [!WARNING]
511518
>
512-
> Do not forget that this code will be used in the browser and not all browsers support latest ECMA features like `let`, `const`, `arrow function expression` and etc. We recommend using [`babel-loader`](https://webpack.js.org/loaders/babel-loader/) for support latest ECMA features.
519+
> Do not forget that this code will be used in the browser and not all browsers support latest ECMA features like `let`, `const`, `arrow function expression`, etc. We recommend using [`babel-loader`](https://webpack.js.org/loaders/babel-loader/) to support the latest ECMA features.
513520
514521
> [!WARNING]
515522
>
516-
> Do not forget that some DOM methods may not be available in older browsers, we recommended use only [DOM core level 2 properties](https://caniuse.com/#search=DOM%20Core), but it is depends what browsers you want to support
523+
> Do not forget that some DOM methods may not be available in older browsers. We recommended using only [DOM core level 2 properties](https://caniuse.com/#search=DOM%20Core), but it depends on which browsers you want to support.
517524
518525
**webpack.config.js**
519526

@@ -538,7 +545,7 @@ module.exports = {
538545
};
539546
```
540547

541-
A new `<style>`/`<link>` elements will be inserted into at bottom of `body` tag.
548+
New `<style>`/`<link>` elements will be inserted at the bottom of the `body` tag.
542549

543550
Examples:
544551

@@ -590,7 +597,7 @@ module.exports = {
590597
};
591598
```
592599

593-
You can pass any parameters to `style.use(options)` and this value will be passed to `insert` and `styleTagTransform` functions.
600+
You can pass any parameters to `style.use(options)` and this value will be passed to the `insert` and `styleTagTransform` functions.
594601

595602
**insert-function.js**
596603

@@ -693,15 +700,15 @@ Default: `undefined`
693700

694701
#### `string`
695702

696-
Allows to setup absolute path to custom function that allows to override default behavior styleTagTransform.
703+
Allows you to setup an absolute path to a custom function that allows to override default `styleTagTransform` behavior.
697704

698705
> [!WARNING]
699706
>
700-
> Do not forget that this code will be used in the browser and not all browsers support latest ECMA features like `let`, `const`, `arrow function expression` and etc, we recommend use only ECMA 5 features, but it is depends what browsers you want to support
707+
> Do not forget that this code will be used in the browser and not all browsers support latest ECMA features like `let`, `const`, `arrow function expression`, etc. We recommend use only ECMA 5 features, but it depends on which browsers you want to support.
701708
702709
> [!WARNING]
703710
>
704-
> Do not forget that some DOM methods may not be available in older browsers, we recommended use only [DOM core level 2 properties](https://caniuse.com/#search=DOM%20Core), but it depends what browsers you want to support
711+
> Do not forget that some DOM methods may not be available in older browsers. We recommended using only [DOM core level 2 properties](https://caniuse.com/#search=DOM%20Core), but it depends on which browsers you want to support.
705712
706713
**webpack.config.js**
707714

@@ -733,7 +740,8 @@ module.exports = {
733740
type base = number;
734741
```
735742

736-
This setting is primarily used as a workaround for [css clashes](https://github.com/webpack-contrib/style-loader/issues/163) when using one or more [DllPlugin](https://robertknight.me.uk/posts/webpack-dll-plugins/)'s. `base` allows you to prevent either the _app_'s css (or _DllPlugin2_'s css) from overwriting _DllPlugin1_'s css by specifying a css module id base which is greater than the range used by _DllPlugin1_ e.g.:
743+
This setting is primarily used as a workaround for [CSS clashes](https://github.com/webpack-contrib/style-loader/issues/163) when using one or more [DllPlugin](https://robertknight.me.uk/posts/webpack-dll-plugins/)s.
744+
`base` allows you to prevent either the _app_'s CSS (or _DllPlugin2_'s css) from overwriting _DllPlugin1_'s CSS by specifying a CSS module ID base that is greater than the range used by _DllPlugin1_ e.g.:
737745

738746
**webpack.dll1.config.js**
739747

@@ -797,9 +805,10 @@ type esModule = boolean;
797805
Default: `true`
798806

799807
By default, `style-loader` generates JS modules that use the ES modules syntax.
800-
There are some cases in which using ES modules is beneficial, like in the case of [module concatenation](https://webpack.js.org/plugins/module-concatenation-plugin/) and [tree shaking](https://webpack.js.org/guides/tree-shaking/).
801808

802-
You can enable a CommonJS modules syntax using:
809+
There are some cases in which using ES modules is beneficial, such as in the case of [module concatenation](https://webpack.js.org/plugins/module-concatenation-plugin/) and [tree shaking](https://webpack.js.org/guides/tree-shaking/).
810+
811+
You can enable a CommonJS module syntax using:
803812

804813
**webpack.config.js**
805814

@@ -821,15 +830,15 @@ module.exports = {
821830

822831
## Examples
823832

824-
### Recommend
833+
### Recommended
825834

826-
For `production` builds it's recommended to extract the CSS from your bundle being able to use parallel loading of CSS/JS resources later on.
827-
This can be achieved by using the [mini-css-extract-plugin](https://github.com/webpack-contrib/mini-css-extract-plugin), because it creates separate css files.
828-
For `development` mode (including `webpack-dev-server`) you can use `style-loader`, because it injects CSS into the DOM using multiple `<style></style>` and works faster.
835+
For `production` builds, it's recommended to extract the CSS from your bundle to enable parallel loading of CSS/JS resources later on.
836+
This can be achieved by using the [mini-css-extract-plugin](https://github.com/webpack-contrib/mini-css-extract-plugin), because it creates separate CSS files.
837+
For `development` mode (including `webpack-dev-server`), you can use `style-loader`, because it injects CSS into the DOM using multiple `<style></style>` tags and works faster.
829838

830839
> [!WARNING]
831840
>
832-
> Do not use together `style-loader` and `mini-css-extract-plugin`.
841+
> Do not use `style-loader` and `mini-css-extract-plugin` together.
833842
834843
**webpack.config.js**
835844

@@ -859,7 +868,7 @@ module.exports = {
859868

860869
> [!WARNING]
861870
>
862-
> It is not allowed to use JavaScript reserved words in css class names.
871+
> It is not allowed to use JavaScript reserved words in CSS class names.
863872
864873
> [!WARNING]
865874
>
@@ -897,7 +906,7 @@ import * as styles from "./styles.css";
897906
console.log(styles.fooBaz, styles.bar, styles["my-class"]);
898907
```
899908

900-
You can enable a ES module named export using:
909+
You can enable an ES module named export using:
901910

902911
**webpack.config.js**
903912

@@ -928,7 +937,8 @@ module.exports = {
928937

929938
### Source maps
930939

931-
The loader automatically inject source maps when previous loader emit them.
940+
The loader automatically injects source maps when the previous loader emits them.
941+
932942
Therefore, to generate source maps, set the `sourceMap` option to `true` for the previous loader.
933943

934944
**webpack.config.js**
@@ -955,8 +965,8 @@ If you are using a [Content Security Policy](https://www.w3.org/TR/CSP3/) (CSP),
955965

956966
There are two ways to work with `nonce`:
957967

958-
- using the `attributes` option
959-
- using the `__webpack_nonce__` variable
968+
- Using the `attributes` option
969+
- Using the `__webpack_nonce__` variable
960970

961971
> [!WARNING]
962972
>
@@ -1155,7 +1165,7 @@ module.exports = {
11551165

11561166
#### Custom Elements (Shadow DOM)
11571167

1158-
You can define custom target for your styles for the `lazyStyleTag` type.
1168+
You can define custom target for your styles when using the `lazyStyleTag` type.
11591169

11601170
**insert-function.js**
11611171

@@ -1197,7 +1207,7 @@ module.exports = {
11971207
};
11981208
```
11991209

1200-
Insert styles to the provided element or to the `head` tag if target isn't provided.
1210+
Insert styles to the provided element, or into the `head` tag if the target isn't provided.
12011211

12021212
**custom-square.css**
12031213

@@ -1248,7 +1258,8 @@ export default CustomSquare;
12481258

12491259
## Contributing
12501260

1251-
Please take a moment to read our contributing guidelines if you haven't yet done so.
1261+
We welcome all contributions!
1262+
If you're new here, please take a moment to review our contributing guidelines before submitting issues or pull requests.
12521263

12531264
[CONTRIBUTING](./.github/CONTRIBUTING.md)
12541265

0 commit comments

Comments
 (0)