Skip to content

Commit f1c1049

Browse files
committed
feat!: null is no longer allowed as a size, replaced by "original"
1 parent 9b66de4 commit f1c1049

17 files changed

Lines changed: 542 additions & 354 deletions

README.md

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -54,7 +54,7 @@ module.exports = {
5454
{
5555
loader: "webpack-image-srcset-loader",
5656
options: {
57-
sizes: ["500w", "1000w", "1500w", null],
57+
sizes: ["480w", "1024w", "1920w", "2560w", "original"],
5858
},
5959
},
6060
"webpack-image-resize-loader",
@@ -85,18 +85,18 @@ import webpSrcSet from "./some_pic.jpg?srcset&format=webp";
8585
// webpSrcSet will be "00[...]5.webp 500w, 40[...]3.webp 1000w, 76[...]b.webp 1500w, b1[...]c.webp"
8686
```
8787

88-
| Name | Type | Default | Description |
89-
| --------------------------------------------------- | ------------------ | --------- | -------------------------------------------------------------------------------------------- |
90-
| **[`sizes`](#sizes)** | `(string\|null)[]` | undefined | Sizes in the output srcset. |
91-
| **[`scaleUp`](#scaleup)** | `boolean` | `false` | Whether or not to scale up the image when the desired width is greater than the image width. |
92-
| **[`customOptionsFactory`](#customoptionsfactory)** | `function` | undefined | A function that returns the option to be passed on to the next loader. |
93-
| **[`esModule`](#esmodule)** | `boolean` | `true` | Whether the export is in ES modules syntax or CommonJS modules syntax |
88+
| Name | Type | Default | Description |
89+
| --------------------------------------------------- | ------------ | --------- | -------------------------------------------------------------------------------------------- |
90+
| **[`sizes`](#sizes)** | `(string)[]` | undefined | Sizes in the output srcset. |
91+
| **[`scaleUp`](#scaleup)** | `boolean` | `false` | Whether or not to scale up the image when the desired width is greater than the image width. |
92+
| **[`customOptionsFactory`](#customoptionsfactory)** | `function` | undefined | A function that returns the option to be passed on to the next loader. |
93+
| **[`esModule`](#esmodule)** | `boolean` | `true` | Whether the export is in ES modules syntax or CommonJS modules syntax |
9494

9595
### `sizes`
9696

97-
An array containing strings in the format `"[number]w"`, `"[number]x"`, or `null`. The numbers cannot contain decimals.
97+
An array containing strings in the format `"[number]w"`, `"[number]x"`, or `"original"`. The numbers cannot contain decimals.
9898

99-
Allowed: `["10w", "1x", "2x", null]`
99+
Allowed: `["10w", "1x", "2x", "original"]`
100100

101101
Not allowed: `["10.0w", "1.5x", "2.0x"]`
102102

@@ -106,7 +106,7 @@ When using `"[number]x"`, the original size of the image will be used for the gr
106106

107107
When true, if the desired width is greater than the image width, the size will not be included in the output srcset string. For example, if the original image is `10×10` in size, and the `sizes` array is `["5w", "10w", "15w"]`, when `scaleUp` is `true` the output string is `"image1.jpg 5w, image2.jpg 10w, image3.jpg 15w"`, when `scaleUp` is `false` the output string is `"image1.jpg 5w, image2.jpg 10w"`.
108108

109-
Note: this option has no effect on `"[number]x"` or `null`
109+
Note: this option has no effect on `"[number]x"` or `"original"`
110110

111111
### `customOptionsFactory`
112112

@@ -122,12 +122,12 @@ If you wish to use a resize loader other than [webpack-image-resize-loader](http
122122
}
123123
```
124124

125-
For example, if `sizes` is `["10w", "1x", "2x", null]`, `customOptionsFactory` will be called with
125+
For example, if `sizes` is `["10w", "1x", "2x", "original"]`, `customOptionsFactory` will be called with
126126

127127
- `customOptionsFactory(10, undefined, existingOptions)` for `10w`
128128
- `customOptionsFactory(undefined, 1, existingOptions)` for `1x`
129129
- `customOptionsFactory(undefined, 2, existingOptions)` for `2x`
130-
- `customOptionsFactory(undefined, undefined, existingOptions)` for `null`
130+
- `customOptionsFactory(undefined, undefined, existingOptions)` for `"original"`
131131

132132
### `esModule`
133133

examples/react/webpack.config.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ module.exports = {
2424
{
2525
loader: "webpack-image-srcset-loader",
2626
options: {
27-
sizes: ["480w", "1024w", "1920w", "2560w", null],
27+
sizes: ["480w", "1024w", "1920w", "2560w", "original"],
2828
},
2929
},
3030
"webpack-image-resize-loader",

examples/vue/vue.config.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ module.exports = {
1010
.use("srcset")
1111
.loader("webpack-image-srcset-loader")
1212
.options({
13-
sizes: ["480w", "1024w", "1920w", "2560w", null],
13+
sizes: ["480w", "1024w", "1920w", "2560w", "original"],
1414
esModule: false,
1515
})
1616
.end()

0 commit comments

Comments
 (0)