Skip to content

Commit 82f3bc7

Browse files
authored
docs: clarify what context does (#736)
1 parent 8e93128 commit 82f3bc7

File tree

1 file changed

+6
-8
lines changed

1 file changed

+6
-8
lines changed

README.md

Lines changed: 6 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -302,7 +302,7 @@ type context = string;
302302

303303
Default: `options.context|compiler.options.context`
304304

305-
A path that determines how to interpret the `from` path.
305+
A path to be (1) prepended to `from` and (2) removed from the start of the result path(s).
306306

307307
> **Warning**
308308
>
@@ -328,17 +328,15 @@ module.exports = {
328328
};
329329
```
330330

331-
The `context` option can be an absolute or relative path. If `context` is a relative, then it is converted to absolute based to `compiler.options.context`
331+
`context` can be an absolute path or a relative path. If it is a relative path, then it will be converted to an absolute path based on `compiler.options.context`.
332332

333-
To determine the structure from which the found resources will be copied to the destination folder, the `context` option is used.
333+
`context` should be explicitly set only when `from` contains a glob. Otherwise, `context` is automatically set, based on whether `from` is a file or a directory:
334334

335-
If `from` is a file, then `context` is equal to the directory in which this file is located. Accordingly, the result will be only the file name.
335+
If `from` is a file, then `context` is its directory. The result path will be the filename alone.
336336

337-
If `from` is a directory, then `context` is the same as `from` and is equal to the directory itself. In this case, the result will be a hierarchical structure of the found folders and files relative to the specified directory.
337+
If `from` is a directory, then `context` equals `from`. The result paths will be the paths of the directory's contents (including nested contents), relative to the directory.
338338

339-
If `from` is a glob, then regardless of the `context` option, the result will be the structure specified in the `from` option
340-
341-
More [`examples`](#examples)
339+
The use of `context` is illustrated by these [`examples`](#examples).
342340

343341
#### `globOptions`
344342

0 commit comments

Comments
 (0)