đ Excited to release the create-guten-block toolkit today. In this post, I am going to share what is create-guten-block (cgb), what is the motivation & philosophy behind building this dev-toolbox, and the story of how I am releasing it to the public after ~200 commits and ~90 version releases. Letâs start with intro firstâŚ
đ Introducing Create Guten Block!

create-guten-block (đ at GitHub for updates) is a zero-configuration dev-toolkit (#0CJS) to develop WordPress Gutenberg blocks in a matter of minutes without configuring React, Webpack, ES6/7/8/Next, ESLint, Babel, etc.
Create Guten Block is not like other starter-kits or boilerplates. Itâs a developerâs toolbox which is continuously updated. Since it has zero-configuration, you can always update it without any changes in your code. Thatâs actually why I built it.
đ <a href="https://github.com/ahmadawais/create-guten-block" rel="nofollow noopener" target="_blank">create-guten-block</a> is:
- đĽÂ Versioned â
- 𤠠Updatable â
- đ Set of sane-defaults â
- đ ONE singleÂ
cgb-scripts dependency â
But what is it?!
Whatâs Included?
Your dev-environment will have everything you need to build a modern next-gen WordPress Gutenberg plugin:
- React, JSX, and ES6 syntax support.
- Webpack dev/production build process behind the scene.
- Language extras beyond ES6 like the object spread operator.
- Auto-prefixed CSS, so you donât needÂ
-webkit or other prefixes. - A build script to bundle JS, CSS, and images for production with source-maps.
- Hassle-free updates for the above tools with a single dependencyÂ
cgb-scripts.
Philosophy
- One Dependency:Â There is just one build dependency. It uses Webpack, Babel, ESLint, and other amazing projects, but provides a cohesive curated experience on top of them.
- No Configuration Required:Â You donât need to configure anything. A reasonably good configuration of both development and production builds is handled for you so you can focus on writing code.
- No Lock-In:Â You canÂ
eject to a custom setup at any time. Run a single command, and all the configuration and build dependencies will be moved directly into your project, so you can pick up right where you left off.
Why <a href="https://github.com/ahmadawais/create-guten-block" rel="nofollow noopener" target="_blank">create-guten-block</a>?
Well, itâs really hard to configure things like Webpack, React, ES 6/7/8/Next, ESLint, Babel, etc. before you â even start writing â a Hello WorldGutenberg block. Then thereâs the fact that you have to maintain and constantly update your configuration with all the new tools and growth in the JavaScript community â thatâs not an easy thing to do.
create-guten-block hides all this configuration away in an optimized package that we call cgb-scripts. This package is the only dependency in your projects. We keep cgb-scripts up to date while you go ahead and create the next best WordPress themes and plugins.
So, thatâs what I dreamt about for the next couple of months. How do I solve this problem for the WordPress community, eh?
After building WPGulp and Gutenberg Boilerplate and lot of other open source software that thousands of developers are using â I started receiving lots of feedback on how itâs limiting in its architecture which is complex â and by the way, these boilerplates went stale quite a few times.
I knew this was not right.
Â
So, yes! I went ahead and built a solution â a zero-config-js #0CJS WordPress developersâ toolkit called <a href="https://github.com/ahmadawais/create-guten-block" rel="nofollow noopener" target="_blank">create-guten-block</a>! Enough talk, letâs stop it right here and actually explore the toolkit.
<
div>
GETTING STARTED!
Itâs really easy to get started with create-guten-block. Just install it as a global module and run it to create your next-gen Gutenberg block plugin for WordPress.
đŚ
Did I tell you to star đ it at GitHub for updates and to show appreciation or to report back any issues you face? Hmm⌠lemme think?!
OK! OK! Letâs get you started!
â STEP #0
If you donât have Node.js + npm installed then read this step, otherwise jump to the Step #1 below.
In case you are an absolute beginner to the world of Node.js, JavaScript, and npm packages â all you need to do is go to the Nodeâs site download + install Node on your system. This will install both Node.js and npm, i.e., node package manager â the command line interface of Node.js.
You can verify the install by opening your terminal app and typingâŚ
node -v
# Results into v9.4.0 â make sure you have Node >= 8 installed.
and thenâŚ
npm -v
# Results into 5.6.0 â make sure you have npm >= 5.2 installed.
â STEP #1
Install create-guten-block globally on your system.
Youâll need to have Node >= 8 on your local development machine (but itâs not required on the server). You can use nvm(macOS/Linux) or nvm-windows to easily switch Node versions between different projects.
npm install create-guten-block --global
Hold on, itâll take a couple of minutes to install.
â STEP #2
Now all you have to do is create a Gutenberg block and start building. Itâs done by running the create-guten-block command and providing it with a unique name for a WordPress plugin that will get created. The name can a single word or hyphenated multiple words.
Now letâs run the following command.
create-guten-block my-block
It will create a directory called my-block inside the current folder. Inside that directory, it will generate the initial project structure and install the transitive dependencies:
INSIDE: /local_dev_site.tld/wp-content/plugins/my-block
âââ plugin.php
âââ package.json
âââ README.md
|
âââ dist
| âââ blocks.build.js
| âââ blocks.editor.build.css
| âââ blocks.style.build.css
|
âââ src
âââ block
| âââ block.js
| âââ editor.scss
| âââ style.scss
|
âââ blocks.js
âââ common.scss
âââ init.php
No configuration or complicated folder structures, just the files you need to build your app.
â STEP #3
Once the installation is done, you can open your project folder and run the start script.
Letâs do that.
cd my-block
npm start
You can also use yarn start if thatâs your jam.
This runs the plugin in development mode. To produce production code run npm run build. You will see the build messages, errors, and lint warnings in the console.
Workflow!
There are just three scripts that you can use in your <a href="https://github.com/ahmadawais/create-guten-block" rel="nofollow noopener" target="_blank">create-guten-block</a> workflow. With these three scripts, you can develop, build, and eject your plugin.
đ npm start
- Use to compile and run the block in development mode.
- Watches for any changes and reports back any errors in your code.
đ npm run build
- Use to build production code for your block insideÂ
dist folder. - Runs once and reports back the gzip file sizes of the produced code.
đ npm run eject
- Use to eject your plugin out ofÂ
create-guten-block. - Provides all the configurations so you can customize the project as you want.
- Itâs a one-way street,Â
eject and you have to maintain everything yourself. - You donât normally have toÂ
eject a project because by ejecting you lose the connection withÂcreate-guten-block and from there onwards you have to update and maintain all the dependencies on your own.
Thatâs about it.
TL;DR
Too long, didnât read? Hereâs a shorter version.
Open the terminal app and run the following commands.
- â
 Install/Update:Â
npm install create-guten-block --global - đ°Â Create:Â
create-guten-block my-block â Run inside local WP install E.g.Â/wp.local/wp-content/plugins/ directory. - đ Browse:Â
cd my-block â Open the newly created plugin directory. - âťď¸Â Run:Â
npm start â For development. - đŚÂ Run:Â
npm run build â For production build. - â Run:Â
npm run eject â To customize, update, and maintain all by yourself.
Create-Guten-Block has been tested to work on macOS, but must also work on Windows, and Linux. If something doesnât work, kindly file an issue â
Updating to New Releases
Create Guten Block is divided into two packages:
create-guten-block is a global command-line utility that you use to create new WP Gutenberg plugins.cgb-scripts is a development dependency in the generated plugin projects.
npm install create-guten-block --global
You almost never need to update create-guten-block itself: it delegates all the setup to cgb-scripts. But as this project matures, there might be a few changes over time and you can re-run the global install.
When you run create-guten-block, it always creates the project with the latest version of cgb-scripts so youâll get all the new features and improvements in newly created plugins automatically.
â
 To update an existing project to a new version of cgb-scripts, open the changelog, find the version youâre currently on (check package.json in your pluginâs folder if youâre not sure), and apply the migration instructions for the newer versions.
đ°Â In most cases bumping the cgb-scripts version in the package.json and running npm install in this folder should be enough, but itâs good to consult the changelog for potential breaking changes.
We commit to keeping the breaking changes minimal so you can upgrade cgb-scripts painlessly.
Changelog
Read whatâs đŚÂ new, đ improved, đ fixed, and if đ docs got updated.
đ Go read the entire changelog at this link â CGB Changelog â
Nothingâs ever complete, so bear with us while we keep iterating towards a better future.
'Coz every night I lie in bed
The brightest colors fill my head
A million dreams are keeping me awake
I think of what the world could be
A vision of the one I see
A million dreams is all it's gonna take
A million dreams for the world we're gonna make ...
âŚÂ listen to â A million dreams!
Hello, weâre the WordPress Couple!
I (Ahmad Awais) am a Full Stack Web Developer and a regular core contributor at WordPress. My significant other (Maedah Batool) is a Technical Project Manager, and sheâs also a WordPress Core Contributor. Together with our team, we run the TheDevCouple.com.
If youâd like to get insights into our love for open source software, professional full stack development, WordPress community, the growth of JavaScript or growing a family, building, and bootstrapping a business, then subscribe to our premium newsletter called âŁÂ The WordPress Takeaway!
Support our Open Source Projects! đŠ
If youâd like us to keep producing professional free and open source software (FOSS). Consider paying for an hour of my dev-time. Weâll spend two hours on open source for each contribution. Yeah, thatâs right, you pay for one hour and get both of us to spend an hour as a thank you.
Project Backers & WPCouple Partners âĄď¸
This FOSS (free and open source software) project is built, updated and maintained with the help of awesome businesses listed below. Without the support from these amazing companies/individuals, this project would not have been possible. Make sure you check out their awesome services and products. Theyâve earned it. đ
â What/How? Read more about it â
License & Attribution
MIT Š Ahmad Awais.
This project is inspired by the work of more people than I could mention here. But thank you, Dan Abramov for Create React App, Andrew Clark, Sophie Alpert from React.js team, Wes Bos for awesome courses for React, ES6, and Node beginners. Kent C. Dodds for his open source evangelism, WordPress Core Contributors, Gary for keeping everyone sane, Gutenberg developers Matias, Riad, Andrew, Joen, Greg and contributors, and other WordPress community members like Zac for his course on Gutenberg, and also my friend Morten for all the #Guten-motivation, Icons8 for the awesome icons, Maedah for managing this project, and to everyone I forgot.
Whatâs Next?
Yes, thatâs not all done, yet. I have managed to change the codebase and release many updates by now, before actually announcing a stable release.
The next step is to get this toolkit tested and mature the entire app to release version 2.0.0 for that not only do I need your support, I ask that you hop on board and contribute â thatâs the only way forward.
I have created a GitHub issue with the title of đ Creat Guten Block 2.0 Goals + Call for Contributors! In there I have listed a rough roadmap to version 2.0.0.
Goals listed below â without any order of priority:
- đ At the time of writing,Â
create-guten-block and sister scripts have received 3,000+ downloads - đŻÂ Get folks on React, Webpack, and Babel teams to review the configurations for best possible results
- âĄď¸Â Go beyond React â with Preact, Inferno, Marko, Angular, Vue, etc. JavaScript frameworks
- đ More examples need to be documented. Especially a Multi-block example which is easy
- đ°Â Babel 7, Webpack 4, upgrades to follow in the next major version of create-guten-block
- đ§Â ESLint integration needs a refresher â ESLint + Prettier setup is already WIP
- â Refactor code into small modules and maybe make small npm packages
- đ Improve inline documentation throughout the codebase
- đ Build moreÂ
cgb-dev-utils â separation of concerns - đ¤Â Possible integrations: Service Workers from Google
- đŁÂ Possible integrations: Progressive Web Apps
- đťÂ
.env file limited set of customizations - đ¤Â Allow custom forks ofÂ
cgb-scripts - đ Â Improve the entire Webpack defaults
- đ Webpack file handling done right
- đšÂ Webpack image optimization
- đšÂ Webpack Uglify ES6 plugin
- â Webpack + BrowserSync
- đ°Â Multi Block Examples
- đ Â Automated test suit
- đ¤Â Other stuff? #Suggest
- đ PRâs welcomed
What do you say? Comment below. And make sure youâve stargazed đ the GitHub repo for updates!
đ
Building create-guten-block was a lot of work. Itâs easily one of the best software Iâve written and I have exciting improvements coming.
đĽ It would mean the world to me if you Tweet about it, try it out, and contribute.
Peace! âď¸
Feel free to reach out and say đ on Twitter @MrAhmadAwais
UPDATES
- đÂ
<a href="https://github.com/ahmadawais/create-guten-block" rel="nofollow noopener" target="_blank">create-guten-block</a> has gone viral 100+ stargazers on GitHub - đ Woot! Woot! The project is trending on GitHub JavaScript repos today
- đ Humbled to be listed as a trending developer on GitHub today â this is crazy!
- đĽÂ Holly Molly âÂ
<a href="https://github.com/ahmadawais/create-guten-block" rel="nofollow noopener" target="_blank">create-guten-block</a> is now trending in all languages overall on GitHub!








