Develop a Gutenberg block library powered by Vite, with support for build and watch modes.
- Create a new plugin folder
- Create a blank
package.json
file and thennpm i -D vite-plugin-gutenberg-blocks
- Run
npx init
to create adevelopment
folder and aregister-blocks.php
file cd
intodevelopment
- Run
npm i
to install the required dependencies - Run
npm run create
to create a new Gutenberg block - In your plugin's entry PHP file, simply
require_once
theregister-blocks.php
file
From the development
folder you can now npm run dev
and npm run prod
to develop your Gutenberg blocks library with Vite.
- Automatic configuration of Vite
- Copies and creates required assets
- Externalised PostCSS stylesheet processing
- Watch mode for developing your block library
- Hot module reloading is not currently supported