Home

Awesome

Archived and looking for active maintainers. Check out @wordpress/create-block.

<h4 align="center"> <a href="https://github.com/ahmadawais/create-guten-block"> <img src="https://raw.githubusercontent.com/ahmadawais/stuff/master/fix/cgb.png" alt="create-guten-block" /> </a><br><br><br><a href="https://github.com/ahmadawais/create-guten-block"> <img src="https://raw.githubusercontent.com/ahmadawais/stuff/master/fix/cgblogo.png" alt="create-guten-block" /> </a><br><br>

create-guten-block is 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.

DOWNLOADS Learn Node.js CLI Automation Follow @MrAhmadAwais on Twitter

</h4> <br>

πŸ“¦ create-guten-block

create-guten-block is 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.

create-guten-block is:

<br>

Start

GETTING STARTED!

Let's create a WordPress block plugin...

⚑️ Quick Overview

Run step #1 and #2 quickly in one go β€” Run inside local WP install E.g. /wp.local/wp-content/plugins/ directory.

npx create-guten-block my-block
cd my-block
npm start

(npx comes with npm 5.2+ and higher, see instructions for older npm versions)

πŸŽ› If you want to study the detailed installation of step #1 and #2 β€” then take a look at the steps below.

<details> <summary><strong> STEP #0</strong> β€” Don't have <code>Node.js</code> + <code>npm</code> installed? Read this. (CLICK TO EXPAND!)</summary>

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.1.0 β€” make sure you have Node >= 8 installed.

npm -v
# Results into 5.6.0 β€” make sure you have npm >= 5.3 installed.
</details>

β†’ STEP #1

All you have to do is run the following command and it will create a WordPress block plugin. It's done by installing and running the create-guten-block command and providing it with a unique name for a WordPress plugin that will get created.

⚠️ Make sure run this command in your local WordPress install's plugins folder i.e. /local_dev_site.tld/wp-content/plugins/ folder β€” since this command will produce a WordPress plugin that you can go to WP Admin β–ΆοΈŽ Plugins to activate.

npx create-guten-block my-block

(npx comes with npm 5.2+ and higher, see instructions for older npm versions)

npx block

It'll take a couple of minutes to install.

You’ll need to have Node >= 8 and npm >= 5.3 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.

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

β”œβ”€β”€ .gitignore
β”œβ”€β”€ 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 #2

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.

cgb-npm-start

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.

And just like that, you're building your next WordPress plugin with Gutenberg, React.js, ES 6/7/8/Next, transpiled with Babel, which also has ESLint configurations for your code editor to pick up and use automatically.

<br>

More

Workflow!

There are just three scripts that you can use in your create-guten-block workflow. With these three scripts, you can develop, build, and eject your plugin.

πŸ‘‰ npm start

πŸ‘‰ npm run build

πŸ‘‰ npm run eject

That's about it.

<br>

included

What’s Included?

Your environment will have everything you need to build a modern next-gen WordPress Gutenberg plugin:

The tradeoff is that these tools are preconfigured to work in a specific way. If your project needs more customization, you can "eject" and customize it, but then you will need to maintain this configuration.

<br>

Philosophy

Philosophy

<br>

Why

Why create-guten-block?

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 World Gutenberg 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.

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.

<br>

tldr

TL;DR

Too long, didn't read? Here's a shorter version.

Open the terminal app and run the following commands.

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 β†’

<!-- [![Create-guten-block](https://on.ahmda.ws/okiU/c)](/) --> <br>

update

Updating to New Releases

Create Guten Block is divided into two packages:

  1. create-guten-block is a command-line utility that you use to create new WP Gutenberg plugins.
  2. cgb-scripts is a development dependency in the generated plugin projects.

You never need to update create-guten-block itself as it's run via npx and it delegates all the setup to cgb-scripts.

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 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.

<br>

Log

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!

<br>

Hello

Hello, we're The Dev Couple!

Me (Ahmad Awais) and my incredible wife (Maedah Batool) are two engineers who fell in love with open source and then with each other. You can read more about me here. If you or your company use any of my projects or like what I’m doing then consider backing me. I'm in this for the long run. An open-source developer advocate.

Ahmad on Twitter

NodeCLI.com β€” Learn to build Node.js CLI Automation

This repository is part of the NodeCLI.com course.

After building hundreds of developer automation tools used by millions of developers, I am sharing exactly how you can do it yourself with minimum effective effort. Learn to build Node.js & JavaScript based CLI (Command Line Interface) apps. Automate the grunt work, do more in less time, impress your manager, and help the community. β†’ I'm sharing it all in this online video course. Node CLI Automation without wasting a 1,000 hours β†’</p>

Node CLI

Awais on Twitter

<br>

Partners

Project Backers & TheDevCouple Partners ⚑️

This FOSS (free and open source software) project is 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.

β€” What/How? Read more about it β†’

<table width='100%'> <tr> <td width='500'><a target='_blank' href='https://Awais.dev/kinsta'><img src='https://raw.githubusercontent.com/ahmadawais/stuff/master/fix/kinsta.png' /></a></td> <td width='500'><a target='_blank' href='https://mythemeshop.com/?utm_source=TheDevCouple&utm_medium=Partner'><img src='https://raw.githubusercontent.com/ahmadawais/stuff/master/fix/mts.png' /></a></td> </tr> </table> <br>

Thanks

License & Attribution

<div align="left"> <p><a href="https://github.com/ahmadawais"><img alt="GitHub @AhmadAwais" align="center" src="https://img.shields.io/badge/GITHUB-gray.svg?colorB=6cc644&colorA=6cc644&style=flat" /></a>&nbsp;<small><strong>(follow)</strong> TO STAY UP TO DATE ON FREE & OPEN SOURCE SOFTWARE</small></p> <p><a href="https://twitter.com/MrAhmadAwais/"><img alt="Twitter @MrAhmadAwais" align="center" src="https://img.shields.io/badge/TWITTER-gray.svg?colorB=1da1f2&colorA=1da1f2&style=flat" /></a>&nbsp;<small><strong>(follow)</strong> TO GET ONE DEV MINUTE DAILY HOT TIPS & TROLLS</small></p> <p><a href="https://www.youtube.com/AhmadAwais"><img alt="YouTube AhmadAwais" align="center" src="https://img.shields.io/badge/YOUTUBE-gray.svg?colorB=ff0000&colorA=ff0000&style=flat" /></a>&nbsp;<small><strong>(subscribe)</strong> TO TECH TALKS & ONE DEV MINUTE VIDEOS</small></p> <p><a href="https://AhmadAwais.com/"><img alt="Blog: AhmadAwais.com" align="center" src="https://img.shields.io/badge/MY%20BLOG-gray.svg?colorB=4D2AFF&colorA=4D2AFF&style=flat" /></a>&nbsp;<small><strong>(read)</strong> MOSTLY LONG FORM TECHNICAL ARTICLES</small></p> <p><a href="https://www.linkedin.com/in/MrAhmadAwais/"><img alt="LinkedIn @MrAhmadAwais" align="center" src="https://img.shields.io/badge/LINKEDIN-gray.svg?colorB=0077b5&colorA=0077b5&style=flat" /></a>&nbsp;<small><strong>(connect)</strong> WITH THE LINKEDIN PROFILE Y'ALL</small></p> </div>

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, and Christopher Chedeau, Sophie Alpert from React.js team, Kent C. Dodds for his open source evangelism, WordPress Core Contributors, Gary for keeping everyone sane, Gutenberg developers Matias, Riad, Andrew, Ella, Joen, Tammie, 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.

Follow me πŸ‘‹ on Twitter for more updates and questions β†’ Tweet to say Hi

<br /> <br /> <p align="center"> <strong>For anything else, tweet at <a href="https://twitter.com/MrAhmadAwais/" target="_blank" rel="noopener noreferrer">@MrAhmadAwais</a></strong> </p> <div align="center"> <p>I have released a video course to help you learn how to create projects just like this one. Node.js and JavaScript based automation dev-tools and Command-line CLIs β€” <a href="https://NodeCLI.com/?utm_source=github&utm_medium=referral&utm_campaign=ahmadawais/create-guten-block" target="_blank">Learn to build Node.js CLIS β†’</a></p> <br /> <a href="https://NodeCLI.com/?utm_source=github&utm_medium=referral&utm_campaign=ahmadawais/create-guten-block" target="_blank"> <img src="https://raw.githubusercontent.com/ahmadawais/stuff/master/nodecli/featured.jpg" /><br>VSCode</a>

<small><a href="https://NodeCLI.com/?utm_source=github&utm_medium=referral&utm_campaign=ahmadawais/create-guten-block" target="_blank">Node CLI Automation β†’</a></small>

</div> <div align="center"> <p>I have released a video course to help you become a better developer β€” <a href="https://VSCode.pro/?utm_source=github&utm_medium=referral&utm_campaign=ahmadawais/create-guten-block" target="_blank">Become a VSCode Power User β†’</a></p> <br /> <a href="https://VSCode.pro/?utm_source=github&utm_medium=referral&utm_campaign=ahmadawais/create-guten-block" target="_blank"> <img src="https://raw.githubusercontent.com/ahmadawais/shades-of-purple-vscode/master/images/vscodeproPlay.jpg" /><br>VSCode</a>

<small><a href="https://VSCode.pro/?utm_source=github&utm_medium=referral&utm_campaign=ahmadawais/create-guten-block" target="_blank">VSCode Power User Course β†’</a></small>

</div> <br>

VSCode Ahmad on Twitter