Mini-program build plugins
Once registered, the plugin automatically detects the platform and transforms matching modules. Consumers do not edit Axios internals or configure Vite's optimizeDeps.exclude themselves. Register the plugin once in the application build configuration: importing FastAxios or the runtime adapter does not inject a Vite/Webpack plugin. Do not add it twice if the existing build configuration already includes it.
Install the compatibility packages in the application. The plugin does not install dependencies automatically:
pnpm add miniprogram-formdata miniprogram-blobUse the dedicated Vite subpath. The plugin is active only when UNI_PLATFORM starts with mp-:
import { defineConfig } from "vite";
import uniAppAxiosPlugin from "@fast-china/axios/vite";
export default defineConfig({
plugins: [uniAppAxiosPlugin()],
});For Webpack:
import uniAppAxiosPlugin from "@fast-china/axios/webpack";
export default {
plugins: [uniAppAxiosPlugin()],
};The plugin replaces Axios FormData and Blob platform modules and fails the build when the application cannot resolve the required polyfill. H5, App, and ordinary Web builds retain their original modules.
