Theme Bundling & Root Folders
This skill ensures that any new root-level folders added to the WP Rig theme are properly included in the production bundle.
Configuration & Export
Before modifying the theme structure or preparing a bundle, you MUST reference the config/config.json.
- Export Rules: If you add a new root-level directory for assets or plugin overrides (e.g.,
woocommerce/), you MUST add it to export.filesToCopy to ensure it is included in the production bundle.
Reasoning
WP Rig's build system uses a combination of specialized tasks (phpTask, images, fonts, buildJS, buildCSS) and a manual file-copying task (prodPrep).
- Specialized Tasks: These tasks automatically handle specific file types in specific locations (e.g.,
.php files anywhere in the theme, except for excluded directories like node_modules and vendor).
- prodPrep Task: This task manually copies files and folders specified in the
export.filesToCopy property of the theme's configuration. It is used for files that are not handled by specialized tasks or for folders that need to be explicitly included in the bundle.
When you add a new root-level folder to the theme (especially for plugin template overrides like woocommerce/ or tribe-events/), it is mandatory to add it to the export.filesToCopy array in config/config.json.
Why this is necessary:
- Inclusion of Non-PHP Files: While
phpTask will automatically find and process .php files in your new folder, it will ignore other file types (e.g., .css, .js, .json, .svg, .txt). Adding the folder to filesToCopy ensures that all files within it are included in the bundle.
- Explicit Intent: Adding the folder to the configuration explicitly signals that it is a required part of the theme's production bundle.
- Directory Structure Preservation: The
prodPrep task ensures that the directory structure of the specified folders is accurately preserved in the bundled theme.
Decision Tree: Should I add this folder to config.json?
When a new root-level folder is added, ask the following:
Is it a standard WP Rig core folder? (e.g., inc, assets, template-parts, languages)
- No: Proceed to the next question.
- Yes: These are already handled by existing tasks. No action needed.
Is it an excluded/development-only folder? (e.g., node_modules, vendor, tests, bin, scripts, artifacts, optional, wp-cli, childify_backup)
- No: Proceed to the next question.
- Yes: Do not add to
config.json. These should never be bundled.
Is it a plugin template override folder? (e.g., woocommerce, tribe-events, buddypress, edd)
- Yes: Add to
config.json. These must be included in the bundle for the theme to function correctly with those plugins.
Does the folder contain non-PHP files that are required in production?
How to add a folder to config.json
If the folder is woocommerce, you should add it to the export.filesToCopy array in config/config.json.
Example config/config.json:
{
"theme": {
"enableBlocks": true
},
"export": {
"filesToCopy": [
"woocommerce/**/*"
]
}
}
Note: Use the glob pattern folder-name/**/* to ensure all files and subdirectories are included.
Verification
After adding a folder to config.json:
- Run the bundle command:
npm run bundle
- Verify that the new folder and its contents exist in the production theme directory (usually located at
../{theme-slug}).
1---2name: theme-bundling3description: Theme Bundling & Root Folders4---5# Theme Bundling & Root Folders67This skill ensures that any new root-level folders added to the WP Rig theme are properly included in the production bundle.89## Configuration & Export1011Before modifying the theme structure or preparing a bundle, you **MUST** reference the `config/config.json`.1213* **Export Rules:** If you add a new root-level directory for assets or plugin overrides (e.g., `woocommerce/`), you **MUST** add it to `export.filesToCopy` to ensure it is included in the production bundle.1415## Reasoning1617WP Rig's build system uses a combination of specialized tasks (`phpTask`, `images`, `fonts`, `buildJS`, `buildCSS`) and a manual file-copying task (`prodPrep`).1819- **Specialized Tasks**: These tasks automatically handle specific file types in specific locations (e.g., `.php` files anywhere in the theme, except for excluded directories like `node_modules` and `vendor`).20- **prodPrep Task**: This task manually copies files and folders specified in the `export.filesToCopy` property of the theme's configuration. It is used for files that are not handled by specialized tasks or for folders that need to be explicitly included in the bundle.2122When you add a new root-level folder to the theme (especially for plugin template overrides like `woocommerce/` or `tribe-events/`), it is **mandatory** to add it to the `export.filesToCopy` array in `config/config.json`.2324### Why this is necessary:25261. **Inclusion of Non-PHP Files**: While `phpTask` will automatically find and process `.php` files in your new folder, it will ignore other file types (e.g., `.css`, `.js`, `.json`, `.svg`, `.txt`). Adding the folder to `filesToCopy` ensures that *all* files within it are included in the bundle.272. **Explicit Intent**: Adding the folder to the configuration explicitly signals that it is a required part of the theme's production bundle.283. **Directory Structure Preservation**: The `prodPrep` task ensures that the directory structure of the specified folders is accurately preserved in the bundled theme.2930## Decision Tree: Should I add this folder to `config.json`?3132When a new root-level folder is added, ask the following:33341. **Is it a standard WP Rig core folder?** (e.g., `inc`, `assets`, `template-parts`, `languages`)35 - **No**: Proceed to the next question.36 - **Yes**: These are already handled by existing tasks. No action needed.37382. **Is it an excluded/development-only folder?** (e.g., `node_modules`, `vendor`, `tests`, `bin`, `scripts`, `artifacts`, `optional`, `wp-cli`, `childify_backup`)39 - **No**: Proceed to the next question.40 - **Yes**: Do not add to `config.json`. These should never be bundled.41423. **Is it a plugin template override folder?** (e.g., `woocommerce`, `tribe-events`, `buddypress`, `edd`)43 - **Yes**: **Add to `config.json`**. These must be included in the bundle for the theme to function correctly with those plugins.44454. **Does the folder contain non-PHP files that are required in production?**46 - **Yes**: **Add to `config.json`**.4748## How to add a folder to `config.json`4950If the folder is `woocommerce`, you should add it to the `export.filesToCopy` array in `config/config.json`.5152### Example `config/config.json`:5354```json55{56 "theme": {57 "enableBlocks": true58 },59 "export": {60 "filesToCopy": [61 "woocommerce/**/*"62 ]63 }64}65```6667*Note: Use the glob pattern `folder-name/**/*` to ensure all files and subdirectories are included.*6869## Verification7071After adding a folder to `config.json`:72731. Run the bundle command: `npm run bundle`742. Verify that the new folder and its contents exist in the production theme directory (usually located at `../{theme-slug}`).