Skip to content

Commit 622abfa

Browse files
authored
docs: fix typos and improve clarity in README.md (#1262)
1 parent e403be4 commit 622abfa

File tree

1 file changed

+35
-30
lines changed

1 file changed

+35
-30
lines changed

README.md

Lines changed: 35 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,7 @@ pnpm add -D sass-loader sass webpack
4444
4545
`sass-loader` requires you to install either [Dart Sass](https://github.com/sass/dart-sass), [Node Sass](https://github.com/sass/node-sass) on your own (more documentation can be found below) or [Sass Embedded](https://github.com/sass/embedded-host-node).
4646

47-
This allows you to control the versions of all your dependencies, and to choose which Sass implementation to use.
47+
This allows you to control the versions of all your dependencies and to choose which Sass implementation to use.
4848

4949
> [!NOTE]
5050
>
@@ -54,7 +54,7 @@ This allows you to control the versions of all your dependencies, and to choose
5454
>
5555
> [Node Sass](https://github.com/sass/node-sass) does not work with [Yarn PnP](https://classic.yarnpkg.com/en/docs/pnp/) and doesn't support [@use rule](https://sass-lang.com/documentation/at-rules/use).
5656
57-
Chain the `sass-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 or the [mini-css-extract-plugin](https://github.com/webpack-contrib/mini-css-extract-plugin) to extract it into a separate file.
57+
Chain the `sass-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, or with the [mini-css-extract-plugin](https://github.com/webpack-contrib/mini-css-extract-plugin) to extract it into a separate file.
5858

5959
Then add the loader to your webpack configuration. For example:
6060

@@ -96,7 +96,7 @@ module.exports = {
9696
};
9797
```
9898

99-
Finally run `webpack` via your preferred method.
99+
Finally run `webpack` via your preferred method (e.g., via CLI or an npm script).
100100

101101
### The `style` (new API, by default since 16 version) and `outputStyle` (old API) options in `production` mode
102102

@@ -106,13 +106,14 @@ For `production` mode, the `style` (new API, by default since 16 version) and `o
106106

107107
Webpack provides an [advanced mechanism to resolve files](https://webpack.js.org/concepts/module-resolution/).
108108

109-
The `sass-loader` uses Sass's custom importer feature to pass all queries to the webpack resolving engine enabling you to import your Sass modules from `node_modules`.
109+
The `sass-loader` uses Sass's custom importer feature to pass all queries to the webpack resolving engine, enabling you to import your Sass modules from `node_modules`.
110110

111111
```scss
112112
@import "bootstrap";
113113
```
114114

115115
Using `~` is deprecated and should be removed from your code, but we still support it for historical reasons.
116+
116117
Why can you remove it? The loader will first try to resolve `@import` as a relative path. If it cannot be resolved, then the loader will try to resolve `@import` inside [`node_modules`](https://webpack.js.org/configuration/resolve/#resolvemodules).
117118

118119
Prepending module paths with a `~` tells webpack to search through [`node_modules`](https://webpack.js.org/configuration/resolve/#resolvemodules).
@@ -122,22 +123,25 @@ Prepending module paths with a `~` tells webpack to search through [`node_module
122123
```
123124

124125
It's important to prepend the path with only `~`, because `~/` resolves to the home directory.
126+
125127
Webpack needs to distinguish between `bootstrap` and `~bootstrap` because CSS and Sass files have no special syntax for importing relative files.
128+
126129
Writing `@import "style.scss"` is the same as `@import "./style.scss";`
127130

128131
### Problems with `url(...)`
129132

130133
Since Sass implementations don't provide [url rewriting](https://github.com/sass/libsass/issues/532), all linked assets must be relative to the output.
131134

132-
- If you pass the generated CSS on to the `css-loader`, all urls must be relative to the entry-file (e.g. `main.scss`).
133-
- If you're just generating CSS without passing it to the `css-loader`, it must be relative to your web root.
135+
- If you pass the generated CSS on to the `css-loader`, all URLs must be relative to the entry-file (e.g. `main.scss`).
136+
- If you're just generating CSS without passing it to the `css-loader`, URLs must be relative to your web root.
134137

135138
You might be surprised by this first issue, as it is natural to expect relative references to be resolved against the `.sass`/`.scss` file in which they are specified (like in regular `.css` files).
136139

137140
Thankfully there are two solutions to this problem:
138141

139-
- Add the missing url rewriting using the [resolve-url-loader](https://github.com/bholloway/resolve-url-loader). Place it before `sass-loader` in the loader chain.
140-
- Library authors usually provide a variable to modify the asset path. [bootstrap-sass](https://github.com/twbs/bootstrap-sass) for example has an `$icon-font-path`.
142+
- Add the missing URL rewriting using the [resolve-url-loader](https://github.com/bholloway/resolve-url-loader). Place it before `sass-loader` in the loader chain.
143+
144+
- Library authors usually provide a variable to modify the asset path. [bootstrap-sass](https://github.com/twbs/bootstrap-sass) for example, has an `$icon-font-path`.
141145

142146
## Options
143147

@@ -164,7 +168,7 @@ The special `implementation` option determines which implementation of Sass to u
164168
By default, the loader resolves the implementation based on your dependencies.
165169
Just add the desired implementation to your `package.json` (`sass`, `sass-embedded`, or `node-sass` package) and install dependencies.
166170

167-
Example where the `sass-loader` loader uses the `sass` (`dart-sass`) implementation:
171+
Example where the `sass-loader` uses the `sass` (`dart-sass`) implementation:
168172

169173
**package.json**
170174

@@ -177,7 +181,7 @@ Example where the `sass-loader` loader uses the `sass` (`dart-sass`) implementat
177181
}
178182
```
179183

180-
Example where the `sass-loader` loader uses the `node-sass` implementation:
184+
Example where the `sass-loader` uses the `node-sass` implementation:
181185

182186
**package.json**
183187

@@ -190,7 +194,7 @@ Example where the `sass-loader` loader uses the `node-sass` implementation:
190194
}
191195
```
192196

193-
Example where the `sass-loader` loader uses the `sass-embedded` implementation:
197+
Example where the `sass-loader` uses the `sass-embedded` implementation:
194198

195199
**package.json**
196200

@@ -208,8 +212,7 @@ Example where the `sass-loader` loader uses the `sass-embedded` implementation:
208212

209213
> [!NOTE]
210214
>
211-
> Using `optionalDependencies` means that `sass-loader` can fallback to `sass`
212-
> when running on an operating system not supported by `sass-embedded`
215+
> Using `optionalDependencies` means that `sass-loader` can fallback to `sass` when running on an operating system not supported by `sass-embedded`
213216
214217
Be aware of the order that `sass-loader` will resolve the implementation:
215218

@@ -221,7 +224,7 @@ You can specify a specific implementation by using the `implementation` option,
221224

222225
#### `object`
223226

224-
For example, to always use Dart Sass, you'd pass:
227+
For example, to always use `Dart Sass`, you'd pass:
225228

226229
```js
227230
module.exports = {
@@ -293,11 +296,11 @@ Options for [Dart Sass](http://sass-lang.com/dart-sass) or [Node Sass](https://g
293296

294297
> [!NOTE]
295298
>
296-
> The `charset` option is `true` by default for `dart-sass`, we strongly discourage setting this to `false`, because webpack doesn't support files other than `utf-8`.
299+
> The `charset` option is `true` by default for `dart-sass`. We strongly discourage setting this to `false` because webpack doesn't support files other than `utf-8`.
297300
298301
> [!NOTE]
299302
>
300-
> The `syntax` (new API, by default since 16 version)`and`indentedSyntax`(old API) option is`scss`for the`scss`extension,`indented`for the`sass`extension and`css`for the`css` extension.
303+
> The `syntax` (new API, by default since 16 version)`and`indentedSyntax`(old API) option is `scss`for the`scss` extension,`indented`for the`sass`extension and`css`for the`css` extension.
301304
302305
> [!NOTE]
303306
>
@@ -398,7 +401,7 @@ type sourceMap = boolean;
398401

399402
Default: depends on the `compiler.devtool` value
400403

401-
Enables/Disables generation of source maps.
404+
Enables/disables generation of source maps.
402405

403406
By default generation of source maps depends on the [`devtool`](https://webpack.js.org/configuration/devtool/) option.
404407
All values enable source map generation except `eval` and `false`.
@@ -434,9 +437,9 @@ module.exports = {
434437
};
435438
```
436439

437-
> ℹ In some rare cases `node-sass` can output invalid source maps (it is a `node-sass` bug).
440+
> ℹ In some rare cases `node-sass` can output invalid source maps (this is a `node-sass` bug).
438441
>
439-
> In order to avoid this, you can try to update `node-sass` to latest version, or you can try to set within `sassOptions` the `outputStyle` option to `compressed`.
442+
> In order to avoid this, you can try to update `node-sass` to the latest version, or you can try to set within `sassOptions` the `outputStyle` option to `compressed`.
440443
441444
**webpack.config.js**
442445

@@ -586,10 +589,10 @@ type webpackImporter = boolean;
586589

587590
Default: `true`
588591

589-
Enables/Disables the default webpack importer.
592+
Enables/disables the default webpack importer.
590593

591594
This can improve performance in some cases, though use it with caution because aliases and `@import` at-rules starting with `~` will not work.
592-
You can pass your own `importer` to solve this (see [`importer docs`](https://github.com/sass/node-sass#importer--v200---experimental)).
595+
You can pass your own `importer` to solve this (see [`importer` docs](https://github.com/sass/node-sass#importer--v200---experimental)).
593596

594597
**webpack.config.js**
595598

@@ -649,7 +652,7 @@ $known-prefixes: webkit, moz, ms, o;
649652
}
650653
```
651654

652-
The presented code will throw a webpack warning instead logging.
655+
The presented code will throw a webpack warning instead of logging.
653656

654657
To ignore unnecessary warnings you can use the [ignoreWarnings](https://webpack.js.org/configuration/other-options/#ignorewarnings) option.
655658

@@ -691,11 +694,11 @@ Allows you to switch between the `legacy` and `modern` APIs. You can find more i
691694

692695
> [!NOTE]
693696
>
694-
> Using `modern-compiler` and `sass-embedded` together significantly improve performance and decrease built time. We strongly recommend their use. We will enable them by default in a future major release.
697+
> Using `modern-compiler` and `sass-embedded` together significantly improves performance and decreases build time. We strongly recommend their use. We will enable them by default in a future major release.
695698
696699
> [!WARNING]
697700
>
698-
> The sass options are different for the `legacy` and `modern` APIs. Please look at [docs](https://sass-lang.com/documentation/js-api) how to migrate to the modern options.
701+
> The Sass options are different for the `legacy` and `modern` APIs. Please look at [docs](https://sass-lang.com/documentation/js-api) to learn how to migrate to the modern options.
699702
700703
**webpack.config.js**
701704

@@ -726,7 +729,7 @@ module.exports = {
726729

727730
## How to enable `@debug` output
728731

729-
By default, the output of `@debug` messages are disabled.
732+
By default, the output of `@debug` messages is disabled.
730733
Add the following to **webpack.config.js** to enable them:
731734

732735
```js
@@ -742,7 +745,7 @@ module.exports = {
742745

743746
### Extracts CSS into separate files
744747

745-
For production builds it's recommended to extract the CSS from your bundle to be able to use parallel loading of CSS/JS resources later on.
748+
For production builds, it's recommended to extract the CSS from your bundle to enable parallel loading of CSS/JS resources.
746749

747750
There are four recommended ways to extract a stylesheet from a bundle:
748751

@@ -844,9 +847,9 @@ module.exports = {
844847

845848
### Source maps
846849

847-
Enables/Disables generation of source maps.
850+
Enables/disables generation of source maps.
848851

849-
To enable CSS source maps, you'll need to pass the `sourceMap` option to the `sass-loader` _and_ the `css-loader`.
852+
To enable CSS source maps, you'll need to pass the `sourceMap` option to both the `sass-loader` _and_ the `css-loader`.
850853

851854
**webpack.config.js**
852855

@@ -878,11 +881,13 @@ module.exports = {
878881
};
879882
```
880883

881-
If you want to edit the original Sass files inside Chrome, [there's a good blog post](https://medium.com/@toolmantim/getting-started-with-css-sourcemaps-and-in-browser-sass-editing-b4daab987fb0). Checkout [test/sourceMap](https://github.com/webpack-contrib/sass-loader/tree/master/test) for a running example.
884+
If you want to edit the original Sass files inside Chrome, [there's a good blog post](https://medium.com/@toolmantim/getting-started-with-css-sourcemaps-and-in-browser-sass-editing-b4daab987fb0).
885+
Checkout [test/sourceMap](https://github.com/webpack-contrib/sass-loader/tree/master/test) for a working example.
882886

883887
## Contributing
884888

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

887892
[CONTRIBUTING](./.github/CONTRIBUTING.md)
888893

0 commit comments

Comments
 (0)