I made a plugin using default "todo-list" WordPress provides using npx @wordpress/create-block todo-list. Is there a way to convert to work with multiple blocks?
Basically I built "todo-list" as default, then made a new directory blocks/todo-list and moved src/build folders into there. Then edited todo-list.php register_block_type directory from /build to /blocks/todo-list/build. Then updated package.json start/build scripts to:
"build": "wp-scripts build blocks/todo-list/src/index.js --output-path=blocks/todo-list/build",
"start": "wp-scripts start blocks/todo-list/src/index.js --output-path=blocks/todo-list/build"
The file structure would be:
- blocks
- todo-list
- build
- src
- block-2
- build
- src
- node_modules
- package-lock.json
- package.json
- readme.txt
- todo-list.php
I did npm run build and don't see Todo List as a block. I didn't add a block-2 yet, but that would be it. Can this structure work?
Edit: Figured it out and answered below.