The new block editor for WordPress has been with us for a while now. It is possible that you keep avoiding using it, but if you are a developer you will not have another option that to give it a chance and learn the technologies behind it.
I know, you can always choose to use alternatives such as ACF Blocks and keep working inside your comfort zone. But… wouldn’t it be great to learn new things? Developing your own blocks for the new editor natively will always be more efficient.
@wordpress/scripts, also known as
Let’s see what it is and how we can use it in our projects.
A fantastic contact plugin using the block editor. In its simplicity lies the true power of this plugin. I love it, very versatile and it worked perfectly for me.
The @wordpress/scripts package to build projects in WordPress
Luckily, we now have the package
@wordpress/scripts to deal with all this. The first step is to install it using the following
npm command that you will have to execute inside the root folder of your project:
npm install @wordpress/scripts --save-dev
This command will install the package and all its dependencies without you having to worry about anything, and it will put everything inside the
node_modules folder. In addition, with the
--save-dev option we make sure that the package appears as a development dependency of the project, as it will be added to
In order to invoke the scripts included in the package you need to have the following info (at least) in your project’s
Note that within the
scripts attribute of this JSON file we have two commands:
start. To launch any of them we must execute
npm run build or
npm run start in a terminal.
The first command calls
src/index.js and will generate the build in
On the other hand, the
src/index.js file and regenerates the
build/index.js file incrementally after every change.
If you wanted to do tests and start developing code for Gutenberg but everything was too complex, now with
Furthermore, the package
@wordpress/scripts is officially released by the WordPress team. Using this package is a success guarantee, as the same developers who are responsible of developing the WordPress core and the block editor are the ones who created it.
What used to take hours of research in dependency management is now ready and simple to use via a simple command. Go ahead and try the package
@wordpress/scripts and you’ll see that everything is simpler than you think. Tell us your experience by leaving us a comment below!
Featured image by Thao Le Hoang on Unsplash.
Leave a Reply