Skip to content

Commit d0d50d4

Browse files
committed
chore: Improve ordering
1 parent 24a6e50 commit d0d50d4

File tree

1 file changed

+30
-30
lines changed

1 file changed

+30
-30
lines changed

README.md

Lines changed: 30 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -142,6 +142,36 @@ const output = mergeWithCustomize({
142142
})(object1, object2, object3, ...);
143143
```
144144

145+
## **`unique(<field>, <fields>, field => field)`**
146+
147+
`unique` is a strategy used for forcing uniqueness within configuration. It's most useful with plugins when you want to make sure there's only one in place.
148+
149+
The first `<field>` is the config property to look through for duplicates.
150+
151+
`<fields>` represents the values that should be unique when you run the field => field function on each duplicate.
152+
153+
```javascript
154+
const { mergeWithCustomize, unique } = require("webpack-merge");
155+
156+
const output = mergeWithCustomize({
157+
customizeArray: unique(
158+
"plugins",
159+
["HotModuleReplacementPlugin"],
160+
plugin => plugin.constructor && plugin.constructor.name
161+
)
162+
})(
163+
{
164+
plugins: [new webpack.HotModuleReplacementPlugin()]
165+
},
166+
{
167+
plugins: [new webpack.HotModuleReplacementPlugin()]
168+
}
169+
);
170+
171+
// Output contains only single HotModuleReplacementPlugin now and it's
172+
// going to be the last plugin instance.
173+
```
174+
145175
## **`mergeWithRules`**
146176

147177
To support advanced merging needs (i.e. merging within loaders), `mergeWithRules` includes additional syntax that allows you to match fields and apply strategies to match. Consider the full example below:
@@ -211,36 +241,6 @@ assert.deepStrictEqual(
211241

212242
The way it works is that you should annotate fields to match using `match` (or `CustomizeRule.Match` if you are using TypeScript) matching your configuration structure and then use specific strategies to define how particular fields should be transformed.
213243

214-
## **`unique(<field>, <fields>, field => field)`**
215-
216-
`unique` is a strategy used for forcing uniqueness within configuration. It's most useful with plugins when you want to make sure there's only one in place.
217-
218-
The first `<field>` is the config property to look through for duplicates.
219-
220-
`<fields>` represents the values that should be unique when you run the field => field function on each duplicate.
221-
222-
```javascript
223-
const { mergeWithCustomize, unique } = require("webpack-merge");
224-
225-
const output = mergeWithCustomize({
226-
customizeArray: unique(
227-
"plugins",
228-
["HotModuleReplacementPlugin"],
229-
plugin => plugin.constructor && plugin.constructor.name
230-
)
231-
})(
232-
{
233-
plugins: [new webpack.HotModuleReplacementPlugin()]
234-
},
235-
{
236-
plugins: [new webpack.HotModuleReplacementPlugin()]
237-
}
238-
);
239-
240-
// Output contains only single HotModuleReplacementPlugin now and it's
241-
// going to be the last plugin instance.
242-
```
243-
244244
## Development
245245

246246
1. `nvm use`

0 commit comments

Comments
 (0)