You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
"message": "Ternaries must be used instead of || in JSX expressions to avoid the potential for accidental output. Use, for example, {thing1 ? thing1 : thing2}.",
Copy file name to clipboardExpand all lines: README.md
+29-11Lines changed: 29 additions & 11 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -11,9 +11,7 @@ for use when submoduling a plugin. The built branches will include Composer
11
11
dependencies and any compiled front-end assets (if using them).
12
12
13
13
The plugin supports front-end assets which can be enqueued inside
14
-
`src/assets.php`. For plugins that don't require front-end assets, the
15
-
configuration script below will prompt you to delete the front-end files if you
16
-
don't wish to use them.
14
+
`src/assets.php` or from within an entry points `index.php` file. For plugins that don't require front-end assets, the configuration script below will prompt you to delete the front-end files if you don't wish to use them.
17
15
18
16
## Getting Started
19
17
@@ -74,24 +72,44 @@ Run `npm run lint` to run ESLint against all JavaScript files. Linting will also
74
72
happen when running development or production builds.
75
73
76
74
Run `composer test` to run tests against PHPUnit and the PHP code in the plugin.
77
-
## Updating Dependencies
78
75
79
-
To update `@wordpress` dependencies, simply execute:
76
+
### The `entries` directory and entry points
77
+
All directories created in the `entries` directory can serve as entry points and will be compiled with [@wordpress/scripts](https://github.com/WordPress/gutenberg/blob/trunk/packages/scripts/README.md#scripts) into the `build` directory with an accompanied `index.asset.php` asset map.
78
+
79
+
#### Enqueuing Entry Points
80
+
81
+
You can also include an `index.php` file in the entry point directory for enqueueing or registering a script. This file will then be moved to the build directory and will be auto-loaded with the `load_scripts()` function in the `functions.php` file. Alternatively, if a script is to be enqueued elsewhere there are helper functions in the `src/assets.php` file for getting the assets.
82
+
83
+
### Scaffold a block with `create-block`
84
+
85
+
Use the `create-block` command to create custom blocks with [`@wordpress/create-block`](https://developer.wordpress.org/block-editor/reference-guides/packages/packages-create-block/) and follow the prompts to generate all the block assets in the `blocks/` directory.
86
+
Block registration, script creation, etc will be scaffolded from the `bin/create-block/templates/block/` templates. Run `npm run build` to compile and build the custom block. Blocks are enqueued using the `load_scripts()` function in `src/assets.php`.
87
+
88
+
### Updating WP Dependencies
89
+
90
+
Updates the [WordPress dependency packages](https://developer.wordpress.org/block-editor/reference-guides/packages/packages-scripts/#packages-update) used in the project to their latest version.
91
+
92
+
To update `@wordpress` dependencies to their latest version use the packages-update command:
93
+
94
+
```sh
95
+
npm run packages-update
96
+
```
97
+
98
+
This script provides the following custom options:
99
+
100
+
-`--dist-tag` – allows specifying a custom dist-tag when updating npm packages. Defaults to `latest`. This is especially useful when using [`@wordpress/dependency-extraction-webpack-plugin`](https://www.npmjs.com/package/@wordpress/dependency-extraction-webpack-plugin). It lets installing the npm dependencies at versions used by the given WordPress major version for local testing, etc. Example:
80
101
81
102
```sh
82
-
npm run update-dependencies WPVERSION
103
+
npm run packages-update --dist-tag=wp-WPVERSION`
83
104
```
84
105
85
106
Where `WPVERSION` is the version of WordPress you are targeting. The version
86
-
must include both the major and patch version (e.g., `5.9.3`). For example:
107
+
must include both the major and minor version (e.g., `6.1`). For example:
0 commit comments