📖 See Also: Documentation Index | WORDPRESS_GUIDELINES.md | WORDPRESS_CHECKLIST.md
The OpenFields plugin uses an automated build process that:
- Bundles the React admin app via Vite
- Manages versioning across package.json and plugin file
- Copies built assets to the plugin directory
- Creates a distributable ZIP for WordPress.org submission
pnpm build:plugin- Builds the admin React app
- Copies compiled assets to
plugin/assets/ - Ready for immediate testing in WordPress
- Does NOT create a ZIP file
pnpm build:plugin:release- Builds admin React app
- Updates version in
openfields.phpfrom package.json - Copies assets
- Creates a ZIP file at
dist/openfields-X.X.X.zip - Ready for WordPress.org submission
- Version source:
package.json(single source of truth) - Version destinations:
plugin/openfields.phpheader (auto-updated on release)dist/openfields-X.X.X.zipfilenameOPENFIELDS_VERSIONconstant in plugin
Before releasing:
# Update version in package.json
npm version patch # or minor, major
# or manually edit "version" in package.json
# Then run release build
pnpm build:plugin:releaseScripts are already configured with automatic versioning:
wp_enqueue_script(
'openfields-admin',
OPENFIELDS_PLUGIN_URL . 'assets/admin/js/admin.js',
array(),
OPENFIELDS_VERSION, // ← Auto-versioned!
true
);Benefits:
- Browser cache invalidation on version changes
- Automatic in development builds
- Consistent versioning with package.json
After running any build:
- Admin JavaScript:
plugin/assets/admin/js/admin.js - Admin CSS:
plugin/assets/admin/css/admin.css - Minified and optimized via Vite
- Make changes to admin React app (
admin/src/) - Run:
pnpm build:plugin - Test in WordPress
- Commit changes
- Update version:
npm version patch - Run:
pnpm build:plugin:release - Test the ZIP in WordPress
- Create Git tag:
git tag v0.1.0 - Push to repository:
git push origin v0.1.0 - Upload ZIP to WordPress.org
#!/bin/bash
cd /path/to/openfields
pnpm install
pnpm build:plugin:release
# Now dist/openfields-*.zip is ready to deployplugin/
├── openfields.php
├── assets/
│ ├── admin/
│ │ ├── js/
│ │ │ ├── admin.js ← Built from React
│ │ │ └── admin.js.map
│ │ └── css/
│ │ └── admin.css ← Built from React
│ └── ...
└── includes/
└── ...
dist/
└── openfields-0.1.0/
├── openfields.php ← Version updated
├── assets/
│ ├── admin/
│ │ ├── js/admin.js
│ │ └── css/admin.css
│ └── ...
└── includes/
└── ...
dist/
└── openfields-0.1.0.zip ← Ready for submission
The build script uses:
OPENFIELDS_VERSION- Set from version constantROOT_DIR- Auto-detected from script locationBUILD_DIR-dist/directory for release builds
npm install -g pnpmCheck that admin/dist/ exists after Vite build:
ls -la admin/dist/Ensure package.json has proper version format:
"version": "0.1.0"Check permissions on dist/ directory:
chmod -R 755 dist/# Just rebuild React app
pnpm buildcp -r admin/dist/* plugin/assets/admin/cd dist
zip -r openfields-0.1.0.zip openfields/- Always build before committing: Ensures assets are up-to-date
- Test release builds: Run in test WordPress before submitting
- Use semantic versioning:
major.minor.patch - Tag releases in Git: Makes deployment history clear
- Never commit node_modules: Already in .gitignore
Once you're ready for WordPress.org:
- Generate release build:
pnpm build:plugin:release - Test the ZIP: Install in WordPress and verify
- Submit: Upload
dist/openfields-X.X.X.zip - Update GitHub releases with the same ZIP
- Add deploy tag:
git tag v0.1.0 && git push origin v0.1.0
- React app is minified and tree-shaken by Vite
- Source maps included for development debugging
- Production builds are optimized for size
- Versioning ensures fresh cache on updates