@@ -39,34 +39,45 @@ npm add browserslist-load-config -D
3939
4040### loadConfig
4141
42- ``` ts
43- import { loadConfig } from " browserslist-load-config" ;
42+ Loads the browserslist configuration from the specified file or directory, returns the browserslist config of specified environment.
4443
45- // Pass a path to the configuration file
46- const config = loadConfig ({
44+ - ** Type:**
45+
46+ ``` ts
47+ type LoadConfigOptions = {
48+ /**
49+ * Specify the path to the configuration file
50+ * If both `config` and `path` are provided, `config` will be used
51+ */
52+ config? : string ;
4753 /**
4854 * Specify the directory where the configuration file is located
4955 */
50- path: " ./path/to/project/root" ,
51-
56+ path? : string ;
5257 /**
5358 * Specify the environment to load
5459 * @default " production"
5560 */
61+ env? : string ;
62+ };
63+
64+ function loadConfig(opts : LoadConfigOptions ): string [] | undefined ;
65+ ```
66+
67+ - ** Example:**
68+
69+ ``` ts
70+ import { loadConfig } from " browserslist-load-config" ;
71+
72+ // Pass a path to the configuration file
73+ const config = loadConfig ({
74+ path: " ./path/to/project/root" ,
5675 env: " production" ,
5776});
5877
5978// Pass a browserslist config directly
6079const config = loadConfig ({
61- /**
62- * Specify the directory where the configuration file is located
63- */
64- path: " ./path/to/project/root" ,
65-
66- /**
67- * Specify the environment to load
68- * @default " production"
69- */
80+ config: " ./path/to/project/root/.browserslistrc" ,
7081 env: " production" ,
7182});
7283
@@ -78,10 +89,18 @@ console.log(config);
7889 */
7990```
8091
81- If both ` config ` and ` path ` are provided, ` config ` will be used.
82-
8392### findConfig
8493
94+ Finds the browserslist configuration file in the specified directory, returns the resolved browserslist config object.
95+
96+ - ** Type:**
97+
98+ ``` ts
99+ function findConfig(from : string ): Record <string , string []> | undefined ;
100+ ```
101+
102+ - ** Example:**
103+
85104``` ts
86105import { findConfig } from " browserslist-load-config" ;
87106
0 commit comments