npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

create-wp-block

v2.7.0

Published

Extends the @wordpress/create-block package by adding new features for flexible block scaffolding such as support for multiple blocks.

Downloads

6

Readme

Create Single or Multiple WordPress Blocks

Extends the WordPress core @wordpress/create-block package that creates a new block plugin. It's basically a thin wrapper around the core CLI which allows us to expose some new features right now until they're officially available, such as:

  • Single named blocks.
  • Multiple named blocks.
  • Full Tailwind CSS integration.

The create-wp-blocks script is meant to be a useful tool to create blocks with additional functionality currently available in @wordpress/create-block. Hopefully, over time, most (or all) of these extra features will be available in the core package and this one can be deprecated.

New functionality

Specify a block name via the --block (or -b alias). By default in @wordpress/create-block there's no way to name a block, it's always set to the name of the plugin slug. e.g. npx create-wp-block test -b block1.

Note, if the block name is specified but a plugin name (slug) is, then this will trigger interactive mode which is the default behaviour of @wordpress/create-block when no slug is specified.

Optional Tailwind CSS integration is now available via the --tw flag.

Usage

To create a basic plugin containing a single block:

npx create-wp-block todo-list

Note: This produces exactly the same plugin as npx @wordpress/create-block todo-list

Things become interesting when we use the new features:

npx create-wp-block todo-list -b block1

This will create a plugin with the slug todo-list, which contains a single block with the slug block1.

Create multiple blocks with:

npx create-wp-block todo-list -b block1 block2 block3

This will create a plugin with the slug todo-list, which contains three blocks with slugs: block1, block2, block3. Each block is located inside its own sub-folder. e.g. /src/block1/.

Enable full Tailwind integration with the --tw option:

npx create-wp-block todo-list -b block1 block2 block3 --tw

Each block compiles its own Tailwind styles, which is inline with how blocks are compiled with @wordpress/create-block. Blocks continue to maintain their own styles independently.

For quick testing you can disable wp-scripts with the --ns option:

npx create-wp-block todo-list -b block1 block2 block3 --ns

This doesn't install npm modules and creates the block plugin much quicker. However, you'll need to manually run npm install to do an initial build of the plugin block JavaScript code.

Trouble Shooting

If no named blocks are specified then the plugin slug will be used as a fallback.

There will probably be regular updates to this CLI as it's refined and new features are added. Sometimes npx will cache the version of the script which can be annoying. To make sure you're always running the latest release version you can add @latest. e.g. npx create-wp-block@latest myplugin -b one.

For now (at least) there's no interactive mode if a plugin slug is not specified. This is required or the script will exit with a warning message. You're required to enter a plugin slug.

Request a Feature?

Are you looking for a feature to be included in this package? Simply open a new issue and let's talk! All suggestions welcome.