Skip to content

Commit e2c496b

Browse files
authored
docs: fix typos and improve clarity in README.md (#432)
1 parent d59df76 commit e2c496b

File tree

1 file changed

+37
-25
lines changed

1 file changed

+37
-25
lines changed

README.md

Lines changed: 37 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@
1313

1414
# stylus-loader
1515

16-
A Stylus loader for webpack. Compiles Styl to CSS.
16+
A Stylus loader for webpack. Compiles Stylus files into CSS.
1717

1818
## Getting Started
1919

@@ -35,7 +35,7 @@ or
3535
pnpm add -D stylus stylus-loader
3636
```
3737

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

4040
**webpack.config.js**
4141

@@ -52,7 +52,7 @@ module.exports = {
5252
};
5353
```
5454

55-
And run `webpack` via your preferred method.
55+
Finally, run `webpack` using the method you normally use (e.g., via CLI or an npm script).
5656

5757
## Options
5858

@@ -84,9 +84,11 @@ type stylusOptions =
8484

8585
Default: `{}`
8686

87-
You can pass any Stylus specific options to the `stylus-loader` through the `stylusOptions` property in the [loader options](https://webpack.js.org/configuration/module/#ruleoptions--rulequery)
87+
You can pass any Stylus specific options to the `stylus-loader` through the `stylusOptions` property in the [loader options](https://webpack.js.org/configuration/module/#ruleoptions--rulequery).
88+
8889
See the [Stylus documentation](https://stylus-lang.com/docs/js.html).
89-
Options in dash-case should use camelCase.
90+
91+
Options in dash-case should be written in camelCase.
9092

9193
#### `object`
9294

@@ -299,7 +301,7 @@ type webpackImporter = boolean;
299301

300302
Default: `true`
301303

302-
Enables/Disables the default Webpack importer.
304+
Enables/disables the default Webpack importer.
303305

304306
This can improve performance in some cases.
305307
Use it with caution because aliases and `@import` at-rules starting with `~` will not work.
@@ -345,13 +347,14 @@ type additionalData =
345347
Default: `undefined`
346348

347349
Prepends `Stylus` code before the actual entry file.
348-
In this case, the `stylus-loader` will not override the source but just **prepend** the entry's content.
350+
In this case, the `stylus-loader` will not override the source but will simply **prepend** the entry's content.
349351

350-
This is especially useful when some of your Stylus variables depend on the environment:
352+
This is especially useful when some of your Stylus variables depend on the environment.
351353

352354
> [!NOTE]
353355
>
354-
> Since you're injecting code, this will break the source mappings in your entry file. Often there's a simpler solution than this, like multiple Stylus entry files.
356+
> Since you're injecting code, this will break the source mappings in your entry file.
357+
> Often there's a simpler solution than this, such as using multiple Stylus entry files.
355358
356359
#### `string`
357360

@@ -402,7 +405,7 @@ module.exports = {
402405
return "value = 100px" + content;
403406
}
404407

405-
return "value 200px" + content;
408+
return "value = 200px" + content;
406409
},
407410
},
408411
},
@@ -436,7 +439,7 @@ module.exports = {
436439
return "value = 100px" + content;
437440
}
438441

439-
return "value 200px" + content;
442+
return "value = 200px" + content;
440443
},
441444
},
442445
},
@@ -455,7 +458,8 @@ Type:
455458
type implementation = Function | string;
456459
```
457460

458-
The special `implementation` option determines which implementation of Stylus to use. Overrides the locally installed `peerDependency` version of `stylus`.
461+
The `implementation` option allows you to specify which `Stylus implementation` to use.
462+
It overrides the locally installed `peerDependency` version of `stylus`.
459463

460464
#### `function`
461465

@@ -511,9 +515,9 @@ module.exports = {
511515

512516
## Examples
513517

514-
### Normal usage
518+
### Normal Usage
515519

516-
Chain the `stylus-loader` with the [`css-loader`](https://github.com/webpack-contrib/css-loader) and the [`style-loader`](https://github.com/webpack-contrib/style-loader) to immediately apply all styles to the DOM.
520+
Chain `stylus-loader` with the [`css-loader`](https://github.com/webpack-contrib/css-loader) and [`style-loader`](https://github.com/webpack-contrib/style-loader) to immediately apply all styles to the DOM.
517521

518522
**webpack.config.js**
519523

@@ -542,7 +546,8 @@ module.exports = {
542546

543547
### Source maps
544548

545-
To enable sourcemaps for CSS, you'll need to pass the `sourceMap` property in the loader's options. If this is not passed, the loader will respect the setting for webpack source maps, set in `devtool`.
549+
To enable sourcemaps for CSS, you'll need to pass the `sourceMap` property in the loader's options.
550+
If this is not passed, the loader will respect the setting for webpack source maps, set in `devtool`.
546551

547552
**webpack.config.js**
548553

@@ -609,9 +614,9 @@ module.exports = {
609614

610615
### Import JSON files
611616

612-
Stylus does not provide resolving capabilities in the `json` function.
617+
Stylus does not provide resolving capabilities in the `json()` function.
613618
Therefore webpack resolver does not work for `.json` files.
614-
Use [`stylus resolver`](#stylus-resolver).
619+
To handle this, use a [`stylus resolver`](#stylus-resolver).
615620

616621
**index.styl**
617622

@@ -654,34 +659,38 @@ module.exports = {
654659

655660
### In production
656661

657-
Usually, it's recommended to extract the style sheets into a dedicated file in production using the [MiniCssExtractPlugin](https://github.com/webpack-contrib/mini-css-extract-plugin). This way your styles are not dependent on JavaScript.
662+
Usually, it's recommended to extract the style sheets into a dedicated CSS file in production using the [MiniCssExtractPlugin](https://github.com/webpack-contrib/mini-css-extract-plugin). This way your styles are not dependent on JavaScript.
658663

659664
### webpack resolver
660665

661666
Webpack provides an [advanced mechanism to resolve files](https://webpack.js.org/configuration/resolve/).
662667
The `stylus-loader` applies the webpack resolver when processing queries.
663-
Thus you can import your Stylus modules from `node_modules`.
668+
Thus you can import your Stylus modules directly from `node_modules`.
664669

665670
```styl
666671
@import 'bootstrap-styl/bootstrap/index.styl';
667672
```
668673

669-
Using `~` is deprecated and can be removed from your code (**we recommend it**), but we still support it for historical reasons.
674+
Using `~` prefix is deprecated and can be removed from your code (**we recommended**), but we still support it for historical reasons.
675+
670676
Why you can removed it? The loader will first try to resolve `@import`/`@require` as relative, if it cannot be resolved, the loader will try to resolve `@import`/`@require` inside [`node_modules`](https://webpack.js.org/configuration/resolve/#resolvemodules).
677+
671678
Just prepend them with a `~` which tells webpack to look up the [`modules`](https://webpack.js.org/configuration/resolve/#resolvemodules).
672679

673680
```styl
674681
@import "~bootstrap-styl/bootstrap/index.styl";
675682
```
676683

677-
It's important to only prepend it with `~`, because `~/` resolves to the home-directory.
678-
Webpack needs to distinguish between `bootstrap` and `~bootstrap`, because CSS and Styl files have no special syntax for importing relative files.
684+
It's important to only prepend it with `~`, because `~/` resolves to the home-directory, which is different.
685+
686+
Webpack needs to distinguish between `bootstrap` and `~bootstrap`, because CSS and Stylus files have no special syntax for importing relative files.
687+
679688
Writing `@import "file"` is the same as `@import "./file";`
680689

681690
### Stylus resolver
682691

683692
If you specify the `paths` option, modules will be searched in the given `paths`.
684-
This is Stylus default behavior.
693+
This is the default Stylus behavior.
685694

686695
**webpack.config.js**
687696

@@ -715,7 +724,9 @@ module.exports = {
715724

716725
### Extracting style sheets
717726

718-
Bundling CSS with webpack has some nice advantages like referencing images and fonts with hashed urls or [hot module replacement](https://webpack.js.org/concepts/hot-module-replacement/) in development. In production, on the other hand, it's not a good idea to apply your style sheets depending on JS execution. Rendering may be delayed or even a [FOUC](https://en.wikipedia.org/wiki/Flash_of_unstyled_content) might be visible. Thus it's often still better to have them as separate files in your final production build.
727+
Bundling CSS with webpack has some nice advantages like referencing images and fonts with hashed URLs or [hot module replacement](https://webpack.js.org/concepts/hot-module-replacement/) in development.
728+
In production, on the other hand, it's not a good idea to apply your style sheets depending on JS execution.
729+
Rendering may be delayed or even a [FOUC](https://en.wikipedia.org/wiki/Flash_of_unstyled_content) might be visible. Thus it's often still better to have them as separate files in your final production build.
719730

720731
There are two possibilities to extract a style sheet from the bundle:
721732

@@ -724,7 +735,8 @@ There are two possibilities to extract a style sheet from the bundle:
724735

725736
## Contributing
726737

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

729741
[CONTRIBUTING](./.github/CONTRIBUTING.md)
730742

0 commit comments

Comments
 (0)