Assets
Since v2.0, WP Bones compiles your plugin assets with a single webpack.config.js built on top
of @wordpress/scripts. The config
auto-discovers every file under resources/assets/ — you drop a file in the right folder and
yarn build picks it up.
Supported formats:
- Styles — CSS, LESS, Sass
- Scripts — JavaScript, TypeScript
- React apps —
.jsx,.tsx(folder-based or single-file)
Install
yarn installBuild
One-shot production build:
yarn buildWatch mode during development:
yarn devFolder layout
Source tree under resources/assets/:
- index.tsx
React + TS (folder-based)
- widget.tsx
React + TS (single-file)
- admin.scss
Sass - frontend.less
Less - prism.css
CSS
- helpers.ts
TypeScript - prism.js
JavaScript
Compiled output under public/:
- dashboard.js
React bundle - dashboard.asset.php
Deps manifest - widget.js
React bundle
- admin.css
CSS - frontend.css
CSS - prism.css
CSS
- helpers.js
JavaScript - prism.js
JavaScript
Commands
| Command | What it does |
|---|---|
yarn dev | Webpack in watch mode |
yarn build | One-shot production build |
yarn test | Jest via wp-scripts test-unit-js |
yarn format | Prettier on resources/ |
yarn lint | ESLint on resources/ |
Adding a new React app
php bones make:app dashboardScaffolds resources/assets/apps/dashboard/index.tsx with a React 18 + TypeScript template. No
package.json edits required — webpack auto-discovers the new entry.
See also webpack.config.js and
package.json.
Coming from a v1.x gulp-based plugin? Run php bones migrate:to-v2. See the full
Migrating to v2 guide.
