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.
Missing miniprogram-blob or miniprogram-formdata
- Run the install command above in the application directory that owns the mini-program build. In a monorepo, confirm these packages are dependencies of that application.
- Check that the Vite or Webpack plugin is registered and the target platform begins with
mp-. - Rerun your project's existing mini-program build command. Check that the missing-package error is gone and platform output is generated. If your app uploads files, select a test file in the platform tools and verify that the request sends and returns the expected response.
