Packaging (build-package.ps1)
Packaging (build-package.ps1)
build-package.ps1 creates a clean, deployment‑ready bundle of your MZ project with the RPGReact plugin and React UI.
Basics
Run from the project root.
Platforms:
web,windows,mac.Desktop targets include the NW.js runtime when a runtime path can be resolved (see below). Web target does not include a runtime.
Usage
# Show help
./build-package.ps1 -Help
# Web (HTML5)
./build-package.ps1 -Target web
# Windows (runnable; bundles NW.js runtime)
./build-package.ps1 -Target windows -OutDir dist\package-windows
# macOS (runnable; copies .app bundle if available)
./build-package.ps1 -Target mac -OutDir dist\package-macRuntime source (desktop)
The script finds the NW.js runtime in this order:
-RuntimePathparameterruntimePathindeploy.config.jsonEnvironment variable
RMMZ_RUNTIME_PATHAuto‑discovery: scans the parent directory for
Game.exe(Windows) or a.appbundle (macOS)
If not found for desktop targets, the script fails fast with a clear error.
Config file deploy.config.json includes:
Important validations
Ensures
index.html,js/,data/,js/plugins/RPGReact.js,menus/build/existFor desktop: ensures
package.jsonexistsParses
package.jsonand verifiesmainpoints to an existing file (prevents no‑window boot)
Options
-OutDir(defaultdist\package) — Output folder-ConfigPath(defaultdeploy.config.json) — Include/exclude rules and runtimePath-RuntimePath— Path to a desktop runtime (folder containingGame.exeon Windows, or a.appon macOS)-PurgeAssets— Remove unused assets from the OUTPUT package by scanning RPG data and React build files (JS/CSS). See Asset Pruning below for details.
Overrides bundling and minification (plugin JS)
Single source of truth:
js/plugins/rpgreact/overrides.manifest.jsondefines the exact files and order.The script concatenates and prepares each listed file, then minifies to:
js/plugins/rpgreact/RPGReact.overrides.min.js
All unminified override sources (including
custom/) are removed from the output.The main plugin
js/plugins/RPGReact.jsis minified in place.The script fails fast if:
The overrides manifest is missing or invalid,
A listed file is missing/unreadable,
esbuildis not found or minification fails.
Asset Pruning The -PurgeAssets flag removes unused assets from your production build to reduce package size. This is especially important for games using only a subset of the default RMMZ assets.
How it works:
Scans all data files (Actors.json, Items.json, Maps.json, System.json, etc.) for asset references
Scans React build files (JS/CSS) for dynamic imports and asset paths
Includes engine default battlebacks to prevent runtime errors
Removes any assets not found in the scan results
Usage:
Output files:
asset-manifest.txt— List of all kept assets with reasonsasset-mapping.json— Structured data for debugging
Important notes:
Always test without
-PurgeAssetsfirst to ensure the build worksReview
asset-manifest.txtto verify critical assets weren't removedBattlebacks are protected by scanning System.json, all Map files, and including engine defaults
Assets referenced via plugin commands may not be detected automatically
See Asset Pruning Guide for detailed information on how scanning works, troubleshooting missing assets, and customization.
Typical flow
In
menus/:yarn install && yarn release(useyarn buildfor development testing)Ensure your overrides manifest is correct:
js/plugins/rpgreact/overrides.manifest.jsonProject root:
./build-package.ps1 -Target windowsTest the build thoroughly in
dist\packageIf testing succeeds, rebuild with
-PurgeAssetsfor productionRun from
dist\package(or your-OutDir):Game.exe
Important: Always use yarn release for production builds to enable optimizations. Use yarn build only for development testing.
See Also
Asset Pruning Guide — Comprehensive asset pruning documentation
Production Checklist — Pre-release testing checklist
Debugging Guide — Troubleshooting build issues
Last updated