Home for code that will allow us to quickly and consistently create blocks.
This template provides the structure to generate a starter block. The following command will create a folder with all pertinent block files:
npx @wordpress/create-block@latest --template @bostonuniversity/create-block-templates --no-plugin
If you are using the block theme or plugin starter, you can run:
npm run new-id-block
To test locally, run:
npx @wordpress/create-block@latest --template . --no-plugin
There are 2 variants: theme and plugin. The only difference is that plugin will create block-decorative.scss.
- When going through the prompts, you should replace the default namespace value
repo-slug
with your theme or plugin slug. - You should manually replace the generated
block.json
textdomain
value with your actual theme or plugin textdomain. - This script does not
@import
the block’s styles insrc/blocks/blocks-bundled.scss
orsrc/blocks/blocks-decorative.scss
. This must be done manually. - The theme variant does not create the individual
block-decorative.scss
for plugins. This must be done manually.
- Gutenberg Handbook: Using Create-Block Template
- npm Package
- WP Create Block
- @wordpress/create-block
- WP External Project Templates
- Initial Findings
- Template Source
This package is managed through NPM. It can be found here: https://www.npmjs.com/package/@bostonuniversity/create-block-templates
This repo has an action that will run whenever a new release is created.
To learn more about how NPM is managed for BU projects, please read https://developer.bu.edu/webteam/developer/vcs/npm-javascript-packages/
NOTE: you should verify that the package JSON file includes the following to make publishing easier:
"publishConfig": {
"access": "public"
}