@@ -46,24 +46,49 @@ export default {
4646## API
4747
4848``` typescript
49- function externalAssets(pattern : string | RegExp | (string | RegExp )[]);
49+ function externalAssets(
50+ include ? : string | RegExp | (string | RegExp )[],
51+ exclude ? : string | RegExp | (string | RegExp )[],
52+ options ? : { resolve? : string | false | null },
53+ );
5054```
5155
52- ### pattern
56+ ### include / exclude
5357
5458` string | RegExp | (string | RegExp)[] `
5559
56- A picomatch pattern, or array of patterns, which correspond to assets the plugin should operate on.
60+ A valid [ picomatch] [ 9 ] pattern, or array of patterns.
61+ If ` include ` is omitted or has zero length, all imports will be considered as assets.
62+ Otherwise, an import path must match one or more of the ` include ` patterns,
63+ and must not match any of the ` exclude ` patterns.
64+
65+ ** Note** : patterns that include windows paths are normalized to be valid picomatch patterns.
5766
5867``` javascript
68+ import path from " path" ;
69+
5970// Operate on images located in the ./assets directory.
6071externalAssets (" assets/**/*.jpg" );
6172
6273// Operate on images located in the ./assets directory.
6374// and all stylesheet files.
6475externalAssets ([" assets/**/*.{jpg,png}" , / \. (css| scss)$ / ]);
76+
77+ // Operate on all assets except text files.
78+ externalAssets (" assets/**/*" , " **/*.txt" );
79+
80+ // Operate on all assets except text files.
81+ // `__dirname` is the pattern's base dir instead of `process.cwd()`.
82+ externalAssets (path .resolve (__dirname , " assets/**/*" ), " **/*.txt" );
6583```
6684
85+ ### options
86+
87+ - ` resolve ` ` {string | false | null} ` : Optionally resolves the patterns against a directory other than ` process.cwd() ` .
88+ If a ` string ` is specified, then the value will be used as the base directory.
89+ Relative paths will be resolved against ` process.cwd() ` first.
90+ If ` false ` , then the patterns will not be resolved against any directory.
91+
6792## Contributing
6893
6994### Prerequisites
@@ -127,3 +152,4 @@ Please follow the [conventional commits][5] specification, because [semantic-rel
127152[ 6 ] : https://github.com/semantic-release/semantic-release
128153[ 7 ] : https://github.com/concordancejs/concordance/issues/68
129154[ 8 ] : https://jestjs.io/
155+ [ 9 ] : https://github.com/micromatch/picomatch#globbing-features
0 commit comments