Skip to content

Commit 65e4fc0

Browse files
feat: improved validation error messages
1 parent 9c32885 commit 65e4fc0

9 files changed

+1175
-840
lines changed

.github/CONTRIBUTING.md

+8
Original file line numberDiff line numberDiff line change
@@ -147,6 +147,14 @@ module. Thankfully, Github provides a means to do this. Add a dependency to the
147147

148148
Where `{id}` is the # ID of your Pull Request.
149149

150+
## Contributor License Agreement
151+
152+
When submitting your contribution, a CLA (Contributor License Agreement) bot will come by to verify that you signed the [CLA](https://cla.js.foundation/webpack-contrib/css-loader).
153+
If it is your first time, it will link you to the right place to sign it.
154+
However, if you have committed your contributions using an email that is not the same as your email used on GitHub, the CLA bot can't accept your contribution.
155+
156+
Run `git config user.email` to see your Git email, and verify it with [your GitHub email](https://github.com/settings/emails).
157+
150158
## Thanks
151159

152160
For your interest, time, understanding, and for following this simple guide.

README.md

+26-15
Original file line numberDiff line numberDiff line change
@@ -109,21 +109,22 @@ module.exports = {
109109

110110
## Options
111111

112-
| Name | Type | Default | Description |
113-
| :-----------------------------------------: | :-------------------------: | :-----: | :------------------------------------------------- |
114-
| **[`url`](#url)** | `{Boolean\|Function}` | `true` | Enable/Disable `url()` handling |
115-
| **[`import`](#import)** | `{Boolean\|Function}` | `true` | Enable/Disable @import handling |
116-
| **[`modules`](#modules)** | `{Boolean\|String\|Object}` | `false` | Enable/Disable CSS Modules and setup their options |
117-
| **[`sourceMap`](#sourcemap)** | `{Boolean}` | `false` | Enable/Disable Sourcemaps |
118-
| **[`importLoaders`](#importloaders)** | `{Number}` | `0` | Number of loaders applied before CSS loader |
119-
| **[`localsConvention`](#localsconvention)** | `{String}` | `asIs` | Setup style of exported classnames |
120-
| **[`onlyLocals`](#onlylocals)** | `{Boolean}` | `false` | Export only locals |
112+
| Name | Type | Default | Description |
113+
| :-----------------------------------------: | :-------------------------: | :-----: | :--------------------------------------------------------------------- |
114+
| **[`url`](#url)** | `{Boolean\|Function}` | `true` | Enables/Disables `url`/`image-set` functions handling |
115+
| **[`import`](#import)** | `{Boolean\|Function}` | `true` | Enables/Disables `@import` at-rules handling |
116+
| **[`modules`](#modules)** | `{Boolean\|String\|Object}` | `false` | Enables/Disables CSS Modules and their configuration |
117+
| **[`sourceMap`](#sourcemap)** | `{Boolean}` | `false` | Enables/Disables generation of source maps |
118+
| **[`importLoaders`](#importloaders)** | `{Number}` | `0` | Enables/Disables or setups number of loaders applied before CSS loader |
119+
| **[`localsConvention`](#localsconvention)** | `{String}` | `asIs` | Style of exported classnames |
120+
| **[`onlyLocals`](#onlylocals)** | `{Boolean}` | `false` | Export only locals |
121121

122122
### `url`
123123

124124
Type: `Boolean|Function`
125125
Default: `true`
126126

127+
Enables/Disables `url`/`image-set` functions handling.
127128
Control `url()` resolving. Absolute URLs and root-relative URLs are not resolving.
128129

129130
Examples resolutions:
@@ -203,6 +204,7 @@ module.exports = {
203204
Type: `Boolean`
204205
Default: `true`
205206

207+
Enables/Disables `@import` at-rules handling.
206208
Control `@import` resolving. Absolute urls in `@import` will be moved in runtime code.
207209

208210
Examples resolutions:
@@ -285,6 +287,8 @@ module.exports = {
285287
Type: `Boolean|String|Object`
286288
Default: `false`
287289

290+
Enables/Disables CSS Modules and their configuration.
291+
288292
The `modules` option enables/disables the **[CSS Modules](https://github.com/css-modules/css-modules)** specification and setup basic behaviour.
289293

290294
Using `false` value increase performance because we avoid parsing **CSS Modules** features, it will be useful for developers who use vanilla css or use other technologies.
@@ -703,14 +707,12 @@ module.exports = {
703707
Type: `Boolean`
704708
Default: `false`
705709

706-
To include source maps set the `sourceMap` option.
710+
Enables/Disables generation of source maps.
707711

708-
I.e. the `mini-css-extract-plugin` can handle them.
712+
To include source maps set the `sourceMap` option.
709713

710714
They are not enabled by default because they expose a runtime overhead and increase in bundle size (JS source maps do not).
711715

712-
In addition to that relative paths are buggy and you need to use an absolute public path which includes the server URL.
713-
714716
**webpack.config.js**
715717

716718
```js
@@ -734,6 +736,8 @@ module.exports = {
734736
Type: `Number`
735737
Default: `0`
736738

739+
Enables/Disables or setups number of loaders applied before CSS loader.
740+
737741
The option `importLoaders` allows you to configure how many loaders before `css-loader` should be applied to `@import`ed resources.
738742

739743
**webpack.config.js**
@@ -749,7 +753,10 @@ module.exports = {
749753
{
750754
loader: 'css-loader',
751755
options: {
752-
importLoaders: 2, // 0 => no loaders (default); 1 => postcss-loader; 2 => postcss-loader, sass-loader
756+
importLoaders: 2,
757+
// 0 => no loaders (default);
758+
// 1 => postcss-loader;
759+
// 2 => postcss-loader, sass-loader
753760
},
754761
},
755762
'postcss-loader',
@@ -768,6 +775,8 @@ This may change in the future when the module system (i. e. webpack) supports lo
768775
Type: `String`
769776
Default: `undefined`
770777

778+
Style of exported classnames.
779+
771780
By default, the exported JSON keys mirror the class names (i.e `asIs` value).
772781

773782
| Name | Type | Description |
@@ -814,7 +823,9 @@ module.exports = {
814823
Type: `Boolean`
815824
Default: `false`
816825

817-
Export only locals (**useful** when you use **css modules**).
826+
Export only locals.
827+
828+
**Useful** when you use **css modules** for pre-rendering (for example SSR).
818829
For pre-rendering with `mini-css-extract-plugin` you should use this option instead of `style-loader!css-loader` **in the pre-rendering bundle**.
819830
It doesn't embed CSS but only exports the identifier mappings.
820831

lint-staged.config.js

+2-5
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,4 @@
11
module.exports = {
2-
ignore: ['package-lock.json', 'CHANGELOG.md'],
3-
linters: {
4-
'*.js': ['prettier --write', 'eslint --fix', 'git add'],
5-
'*.{json,md,yml,css}': ['prettier --write', 'git add'],
6-
},
2+
'*.js': ['prettier --write', 'eslint --fix', 'git add'],
3+
'*.{json,md,yml,css}': ['prettier --write', 'git add'],
74
};

0 commit comments

Comments
 (0)