Core API

ew-auto-import-tool provides a series of core APIs that can be used programmatically in your projects. Below are the main API functions and their usage.

configureAutoImport

The main function for executing the entire auto-import configuration process.

Function Signature

1async function configureAutoImport(
2  library: Library,
3  projectPath: string = process.cwd()
4): Promise<boolean>;

Parameters

  • library: The component library to configure, type Library (string literal type)
  • projectPath: Project path, defaults to the current working directory

Return Value

  • Promise<boolean>: Promise indicating whether the configuration was successful

Example

1import { configureAutoImport } from "ew-auto-import-tool";
2
3async function setup() {
4  try {
5    const success = await configureAutoImport(
6      "element-plus",
7      "/path/to/project"
8    );
9    if (success) {
10      console.log("Configuration successful!");
11    } else {
12      console.log("Configuration failed!");
13    }
14  } catch (error) {
15    console.error("Configuration error:", error);
16  }
17}
18
19setup();

Module APIs

In addition to the main function, ew-auto-import-tool also provides several module APIs that can be used independently:

These modules can be imported and used separately according to your needs.