Skip to content

Commit 85eb9b1

Browse files
authored
docs: fix typos and improve clarity in README.md (#565)
1 parent 4e126ad commit 85eb9b1

File tree

1 file changed

+35
-24
lines changed

1 file changed

+35
-24
lines changed

README.md

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

1414
# less-loader
1515

16-
A Less loader for webpack. Compiles Less to CSS.
16+
A Less loader for webpack that compiles Less files into CSS.
1717

1818
## Getting Started
1919

@@ -35,7 +35,7 @@ or
3535
pnpm add -D less less-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

@@ -57,7 +57,7 @@ module.exports = {
5757
};
5858
```
5959

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

6262
## Options
6363

@@ -78,11 +78,13 @@ type lessOptions = import('less').options | ((loaderContext: LoaderContext) => i
7878
7979
Default: `{ relativeUrls: true }`
8080
81-
You can pass any Less specific options to the `less-loader` through the `lessOptions` property in the [loader options](https://webpack.js.org/configuration/module/#ruleoptions--rulequery). See the [Less documentation](http://lesscss.org/usage/#command-line-usage-options) for all available options in dash-case. Since we're passing these options to Less programmatically, you need to pass them in camelCase here:
81+
You can pass any Less specific options to the `less-loader` through the `lessOptions` property in the [loader options](https://webpack.js.org/configuration/module/#ruleoptions--rulequery). See the [Less documentation](http://lesscss.org/usage/#command-line-usage-options) for all available options in dash-case.
82+
83+
Since we're passing these options to Less programmatically, you need to pass them in camelCase here:
8284
8385
#### `object`
8486
85-
Use an object to pass options through to Less.
87+
Use an object to pass options directly to Less.
8688
8789
**webpack.config.js**
8890
@@ -116,7 +118,7 @@ module.exports = {
116118

117119
#### `function`
118120

119-
Allows setting the options passed through to Less based off of the loader context.
121+
Allows setting the Less options dynamically based on the loader context.
120122

121123
```js
122124
module.exports = {
@@ -166,10 +168,10 @@ type additionalData =
166168

167169
Default: `undefined`
168170

169-
Prepends/Appends `Less` code to the actual entry file.
171+
Prepends or Appends `Less` code to the actual entry file.
170172
In this case, the `less-loader` will not override the source but just **prepend** the entry's content.
171173

172-
This is especially useful when some of your Less variables depend on the environment:
174+
This is especially useful when some of your Less variables depend on the environment.
173175

174176
> 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 Less entry files.
175177
@@ -277,7 +279,8 @@ type sourceMap = boolean;
277279

278280
Default: depends on the `compiler.devtool` value
279281

280-
By default generation of source maps depends on the [`devtool`](https://webpack.js.org/configuration/devtool/) option. All values enable source map generation except `eval` and `false` value.
282+
By default generation of source maps depends on the [`devtool`](https://webpack.js.org/configuration/devtool/) option.
283+
All values enable source map generation except `eval` and `false` value.
281284

282285
**webpack.config.js**
283286

@@ -318,7 +321,7 @@ type webpackImporter = boolean | "only";
318321

319322
Default: `true`
320323

321-
Enables/Disables the default `webpack` importer.
324+
Enables or disables the default `webpack` importer.
322325

323326
This can improve performance in some cases. Use it with caution because aliases and `@import` from [`node_modules`](https://webpack.js.org/configuration/resolve/#resolvemodules) will not work.
324327

@@ -354,14 +357,16 @@ Type:
354357
type implementation = object | string;
355358
```
356359

357-
> less-loader compatible with Less 3 and 4 versions
360+
> less-loader compatible with both Less 3 and 4 versions
358361
359362
The special `implementation` option determines which implementation of Less to use. Overrides the locally installed `peerDependency` version of `less`.
360363

361364
**This option is only really useful for downstream tooling authors to ease the Less 3-to-4 transition.**
362365

363366
#### `object`
364367

368+
Example using a Less instance:
369+
365370
**webpack.config.js**
366371

367372
```js
@@ -388,6 +393,8 @@ module.exports = {
388393

389394
#### `string`
390395

396+
Example using a resolved Less module path:
397+
391398
**webpack.config.js**
392399

393400
```js
@@ -422,7 +429,7 @@ type lessLogAsWarnOrErr = boolean;
422429

423430
Default: `false`
424431

425-
`Less` warnings and errors will be webpack warnings and errors, not just logs.
432+
`Less` warnings and errors will be treated as webpack warnings and errors, instead of being logged silently.
426433

427434
**warning.less**
428435

@@ -432,7 +439,7 @@ div {
432439
}
433440
```
434441

435-
If `lessLogAsWarnOrErr` is set to `false` it will be just a log and webpack will compile successfully, but if you set this option to `true` webpack will compile fail with a warning.
442+
If `lessLogAsWarnOrErr` is set to `false` it will be just a log and webpack will compile successfully, but if you set this option to `true` webpack will compile fail with a warning(or error), and can break the build if configured accordingly.
436443

437444
**webpack.config.js**
438445

@@ -462,7 +469,7 @@ module.exports = {
462469

463470
### Normal usage
464471

465-
Chain the `less-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.
472+
Chain the `less-loader` with [`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.
466473

467474
**webpack.config.js**
468475

@@ -474,13 +481,13 @@ module.exports = {
474481
test: /\.less$/i,
475482
use: [
476483
{
477-
loader: "style-loader", // creates style nodes from JS strings
484+
loader: "style-loader", // Creates style nodes from JS strings
478485
},
479486
{
480-
loader: "css-loader", // translates CSS into CommonJS
487+
loader: "css-loader", // Translates CSS into CommonJS
481488
},
482489
{
483-
loader: "less-loader", // compiles Less to CSS
490+
loader: "less-loader", // Compiles Less to CSS
484491
},
485492
],
486493
},
@@ -529,7 +536,7 @@ If you want to edit the original Less files inside Chrome, [there's a good blog
529536

530537
### In production
531538

532-
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.
539+
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, improving performance and cacheability.
533540

534541
### Imports
535542

@@ -545,7 +552,7 @@ Thus you can import your Less modules from `node_modules`.
545552
@import "bootstrap/less/bootstrap";
546553
```
547554

548-
Using `~` is deprecated and can be removed from your code (**we recommend it**), but we still support it for historical reasons.
555+
Using `~` prefix (e.g., @import "~bootstrap/less/bootstrap";) is deprecated and can be removed from your code (**we recommend it**), but we still support it for historical reasons.
549556
Why you can removed it? The loader will first try to resolve `@import` as relative, if it cannot be resolved, the loader will try to resolve `@import` inside [`node_modules`](https://webpack.js.org/configuration/resolve/#resolvemodules).
550557

551558
Default resolver options can be modified by [`resolve.byDependency`](https://webpack.js.org/configuration/resolve/#resolvebydependency):
@@ -610,7 +617,7 @@ module.exports = {
610617

611618
### Plugins
612619

613-
In order to use [plugins](http://lesscss.org/usage/#plugins), simply set the `plugins` option like this:
620+
In order to use [Less plugins](http://lesscss.org/usage/#plugins), simply set the `plugins` option like this:
614621

615622
**webpack.config.js**
616623

@@ -635,7 +642,7 @@ module.exports = {
635642

636643
> [!NOTE]
637644
>
638-
> Access to the [loader context](https://webpack.js.org/api/loaders/#the-loader-context) inside the custom plugin can be done using the `pluginManager.webpackLoaderContext` property.
645+
> Access to the [loader context](https://webpack.js.org/api/loaders/#the-loader-context) inside a custom plugin can be done using the `pluginManager.webpackLoaderContext` property.
639646
640647
```js
641648
module.exports = {
@@ -651,7 +658,9 @@ module.exports = {
651658

652659
### Extracting style sheets
653660

654-
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.
661+
Bundling CSS with webpack has some nice advantages like referencing images and fonts with hashed urls or [Hot Module Replacement(HMR)](https://webpack.js.org/concepts/hot-module-replacement/) in development.
662+
663+
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.
655664

656665
There are two possibilities to extract a style sheet from the bundle:
657666

@@ -660,11 +669,13 @@ There are two possibilities to extract a style sheet from the bundle:
660669

661670
### CSS modules gotcha
662671

663-
There is a known problem with Less and [CSS modules](https://github.com/css-modules/css-modules) regarding relative file paths in `url(...)` statements. [See this issue for an explanation](https://github.com/webpack-contrib/less-loader/issues/109#issuecomment-253797335).
672+
There is a known problem when using Less with [CSS modules](https://github.com/css-modules/css-modules) regarding relative file paths in `url(...)` statements.
673+
[See this issue for an explanation](https://github.com/webpack-contrib/less-loader/issues/109#issuecomment-253797335).
664674

665675
## Contributing
666676

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

669680
[CONTRIBUTING](./.github/CONTRIBUTING.md)
670681

0 commit comments

Comments
 (0)