Create Custom Gutenberg Block – Part 1: Setting up the Development Environment
Creating package.json
npm init -y
Next I’ll install WordPress’ scripts that will help us a lot with configuration with this command (which will add the subfolder node_modules and package-lock.json as well):
npm install --save-dev --save-exact @wordpress/scripts
Open the package.json file in your project folder in an editor and find the scripts property. We replace it with two scripts from the WordPress package we just installed:
package.json
"scripts": {
"build": "wp-scripts build",
"start": "wp-scripts start"
},
The “build” script will compile my files. But as it has to be run manually every time a change is made, we will rather use the “start” script while we develop. It will then initiate a “watch mode” where it listens to changes made in any of your script files, and recompiles them whenever you save changes.

Comments
Post a Comment