Skip to content

Vite and Webpack plugins

@fast-china/axios/vite and @fast-china/axios/webpack default-export their respective unplugin adapters.

After registering the plugin once in the application build configuration, transformations run automatically. Do not edit Axios source or repeatedly configure Vite prebundling exclusions. Importing the runtime root does not register the build plugin; compatibility packages are not installed automatically.

Only when process.env.UNI_PLATFORM starts with mp-, the plugin:

  • Replaces the Axios FormData platform module with miniprogram-formdata;
  • Replaces the Axios Blob platform module with miniprogram-blob;
  • Replaces window.FormData with globalThis.FormData in form-data/lib/browser.js;
  • Excludes Axios from Vite dependency prebundling in development.

Missing compatibility packages in the application cause a build error. The plugin exposes no configuration options.

Vite default plugin Build

Creates the Vite plugin for Mini Program Axios FormData/Blob polyfills.

Signature

ts
vitePlugin(options?: unknown): FastAxiosVitePlugin;

Example

ts
import fastAxios from "@fast-china/axios/vite";

export default { plugins: [fastAxios()] };

Input

InputTypeRequired / defaultDescription
optionsunknownOptionalReserved unplugin options; no configuration is required by the current implementation.

Returns

ValueTypeDescription
resultFastAxiosVitePluginVite plugin object containing its name and transform hooks.

Webpack default plugin Build

Creates the Webpack plugin for Mini Program Axios FormData/Blob polyfills.

Signature

ts
webpackPlugin(options?: unknown): FastAxiosWebpackPlugin;

Example

ts
import FastAxiosPlugin from "@fast-china/axios/webpack";

export default { plugins: [FastAxiosPlugin()] };

Input

InputTypeRequired / defaultDescription
optionsunknownOptionalReserved unplugin options; no configuration is required by the current implementation.

Returns

ValueTypeDescription
resultFastAxiosWebpackPluginWebpack plugin object providing apply(compiler).