== imagedirect-create-block
npm package ==
@see https://www.npmjs.com/package/@wordpress/create-block
--template
This argument specifies an external npm package as a template.
npx @wordpress/create-block --template imagedirect-create-block
== Changelog ==
= Version =
- Release
- 1.1.0
== Update package ===
npm publish
imageDirect - Get found in the noise™
Are you looking for a way to share your project configuration? Creating an external project template hosted on npm or located in a local directory is possible. These npm packages can provide custom .mustache
files that replace default files included in the tool for the WordPress plugin or/and the block. It's also possible to override default configuration values used during the scaffolding process.
Providing the main file (index.js
by default) for the package that returns a configuration object is mandatory. Several options allow customizing the scaffolding process.
This optional field allows overriding file templates related to the WordPress plugin shell. The path points to a location with template files ending with the .mustache
extension (nested folders are also supported). When not set, the tool uses its own set of templates.
Example:
const { join } = require( 'path' );
module.exports = {
pluginTemplatesPath: join( __dirname, 'plugin-templates' ),
};
This optional field allows overriding file templates related to the individual block. The path points to a location with template files ending with the .mustache
extension (nested folders are also supported). When not set, the tool uses its own set of templates.
Example:
const { join } = require( 'path' );
module.exports = {
blockTemplatesPath: join( __dirname, 'block-templates' ),
};
This setting is useful when your template scaffolds a WordPress plugin that uses static assets like images or fonts, which should not be processed. It provides the path pointing to the location where assets are located. They will be copied to the assets
subfolder in the generated plugin.
Example:
const { join } = require( 'path' );
module.exports = {
assetsPath: join( __dirname, 'plugin-assets' ),
};
It is possible to override the default template configuration using the defaultValues
field.
Example:
module.exports = {
defaultValues: {
slug: 'my-fantastic-block',
title: 'My fantastic block',
dashicon: 'palmtree',
version: '1.2.3',
},
};
The following configurable variables are used with the template files. Template authors can change default values to use when users don't provide their data.
Project:
wpScripts
(default:true
) – enables integration with the@wordpress/scripts
package and adds common scripts to thepackage.json
.wpEnv
(default:false
) – enables integration with the@wordpress/env
package and adds theenv
script to thepackage.json
.customScripts
(default: {}) – the list of custom scripts to add topackage.json
. It also allows overriding default scripts.npmDependencies
(default:[]
) – the list of remote npm packages to be installed in the project withnpm install
whenwpScripts
is enabled.npmDevDependencies
(default:[]
) – the list of remote npm packages to be installed in the project withnpm install --save-dev
whenwpScripts
is enabled.customPackageJSON
(no default) - allows definition of additional properties for the generated package.json file.
Plugin header fields (learn more):
pluginURI
(no default) – the home page of the plugin.version
(default:'0.1.0'
) – the current version number of the plugin.author
(default:'The WordPress Contributors'
) – the name of the plugin author(s).license
(default:'GPL-2.0-or-later'
) – the short name of the plugin’s license.licenseURI
(default:'https://www.gnu.org/licenses/gpl-2.0.html'
) – a link to the full text of the license.domainPath
(no default) – a custom domain path for the translations (more info).updateURI:
(no default) – a custom update URI for the plugin (related dev note).
Block metadata (learn more):
folderName
(default:.
) – the location for theblock.json
file and other optional block files generated from block templates included in the folder set with theblockTemplatesPath
setting.$schema
(default:https://schemas.wp.org/trunk/block.json
) – the schema URL used for block validation.apiVersion
(default:2
) – the block API version (related dev note).slug
(no default) – the block slug used for identification in the block name.namespace
(default:'create-block'
) – the internal namespace for the block name.title
(no default) – a display title for your block.description
(no default) – a short description for your block.dashicon
(no default) – an icon property thats makes it easier to identify a block (available values).category
(default:'widgets'
) – blocks are grouped into categories to help users browse and discover them. The categories provided by core aretext
,media
,design
,widgets
,theme
, andembed
.attributes
(no default) – block attributes (more details).supports
(no default) – optional block extended support features (more details.editorScript
(default:'file:./index.js'
) – an editor script definition.editorStyle
(default:'file:./index.css'
) – an editor style definition.style
(default:'file:./style-index.css'
) – a frontend and editor style definition.render
(no default) – a path to the PHP file used when rendering the block type on the server before presenting on the front end.customBlockJSON
(no default) - allows definition of additional properties for the generated block.json file.