@shadasd/extract-apis-webpack-plugin
TypeScript icon, indicating that this package has built-in type declarations

1.0.1 • Public • Published

extract-apis-webpack-plugins

从项目中提取 apis 的声明生成 apis-keys.d.ts 文件

背景

  • 每次新定义一个 api 和修改 api 名称需要修改 apis-keys.d.ts 文件,降低了开发效率
  • 每次触发 webpack 的 emit 事件必然会修改 apis-keys.d.ts,影响 git 操作
  • 项目构建时因为项目打包没有 apis.ts 文件引起报错

Install

$ yarn add @shadasd/extract-apis-webpack-plugin --dev

$ npm install @shadasd/extract-apis-webpack-plugin --dev

Usage

webpack:

const { ExtractApisPlugin } = require("@shadasd/extract-apis-webpack-plugin")

plugins: [
  new ExtractApisPlugin()
]

Options

/**
 * 要匹配文件的地址
 * default: ['/src/modules', '/src/components']
 */
paths?: string[];

/**
 * 要匹配的文件名
 * default: apis
 */
filename?: string;

/**
 * 输出文件的地址
 * default: /src/types
 */
outputPath?: string;

/**
 * 输出文件名
 * default: apis-keys.d.ts
 */
outputFilename?: string;

/**
 * 是否打印编译错误日志
 */
verbose?: boolean;

Package Sidebar

Install

npm i @shadasd/extract-apis-webpack-plugin

Weekly Downloads

3

Version

1.0.1

License

MIT

Unpacked Size

24.9 kB

Total Files

6

Last publish

Collaborators

  • chenle