Playground Demo (Composer + Vite)
Composer + Vite example for the WordPress Playground v3 reusable preview workflows.
by adamziel · github.com/adamziel/preview-in-playground-button-v3-example-composer-vite
Install
No release zip yet. The repository archive installs, but the folder name will carry the branch suffix and updates will not flow:
wp plugin install https://github.com/adamziel/preview-in-playground-button-v3-example-composer-vite/archive/refs/heads/main.zipRealistic example for the WordPress Playground v4 reusable preview workflows: a plugin that needs both composer install (PSR-4 autoload + a runtime dep) and npm run build (Vite-bundled admin JS) before it can run.
Demonstrates that the v4 reusable workflows handle a multi-toolchain build with no per-step boilerplate — caller setup is still ~20 lines across two files.
What's in here
playground-demo-plugin.php— main plugin file. Loadsvendor/autoload.php, calls into the namespacedPlaygroundDemo\Noticeclass.src/Notice.php— autoloaded class, uses a real Composer dep (psr/log) to provecomposer installran.composer.json— declares PSR-4 + a runtime require.src-js/admin.js+vite.config.js+package.json— Vite source and config, output goes todist/admin.js(no hash, fixed name) so PHP can enqueue it without reading a manifest..github/workflows/pr-preview-build.yml— runscomposer install --no-dev, thennpm install && npm run build, stages the result with rsync excludes, zips it..github/workflows/pr-preview-publish.yml— exposes the zip, posts the preview button.
Both reusable workflows use WordPress/action-wp-playground-pr-preview at @v4.
Update the build and publish references together when changing versions.
The repository name retains v3 so existing links keep working.