miniprogram-build is a command-line interface (CLI) tool designed to streamline the development workflow for WeChat MiniPrograms. It handles common build tasks such as compiling TypeScript to JavaScript, SCSS/Sass/CSS to MiniProgram's WXSS, HTML/WXML to WXML, and JSON/JSONC to JSON, alongside image compression and file copying. The current stable version is 7.0.3, with frequent patch releases indicating active maintenance. Unlike a framework, it serves as an automation and enhancement tool for existing MiniProgram projects, emphasizing a build-and-watch approach. Its key differentiators include comprehensive support for modern web technologies (TypeScript, SCSS) within the MiniProgram ecosystem and direct integration with the WeChat Developer Tools for features like automatic preview and project upload.
npm install miniprogram-buildVerified import paths — ran on the pinned version, not inferred.
This quickstart demonstrates how to install, initialize, and run `miniprogram-build` for development and production builds within a MiniProgram project.
Ensure WeChat Developer Tools are installed (downloadable from official WeChat MiniProgram developer site) and enable 'Port Settings' in its preferences.
Always use `miniprogram-build build --production` (or `NODE_ENV=production npm run build`) for production builds and rigorously test the resulting MiniProgram package. Do not rely solely on development builds for deployment.
Before upgrading major versions, review the project's GitHub release notes and changelog for detailed migration guides. Test thoroughly in a staging environment.
Double-check the variable naming and interpolation syntax in your source code against the `--var` CLI option. The example `miniprogram-build compile --var.APP_ID=1234567` implies `{{__APP_ID__}}` usage.If installed locally as a dev dependency, run commands using `npx miniprogram-build [command]` or define a script in `package.json` like `"dev": "miniprogram-build dev"` and then `npm run dev`.
Open your WeChat Developer Tools, navigate to 'Settings' -> 'Security Settings', and enable 'Service Port' (服务端口). Ensure the DevTools application remains open while using `autopreview` or `upload` commands.
Create a `tsconfig.json` file in your project's root or specify its path using the `--tsconfig` option, e.g., `miniprogram-build build --tsconfig ./config/tsconfig.json`.