@byteever/scripts
v4.0.1
Published
Zero-config @wordpress/scripts wrapper for ByteEver plugins: src in, build out.
Downloads
69
Maintainers
Readme
@byteever/scripts
Zero-config @wordpress/scripts wrapper for ByteEver plugins.
What it does
byteever-scriptsforwards every command towp-scripts;buildandstartrun through the ByteEver webpack config, andlint-jsthrough the ByteEver ESLint config, unless the project provides its own.- Source at
src/, output atbuild/— thewp-scriptsdefaults, no flags, no config file. - Copies block
block.jsonand PHP files (render.php) into the build; emits async chunks tochunks/. - Entries and externals are declared in
package.jsonunder thebyteeverkey. - Replaces the
byteevertext domain with the plugin's own domain in vendor PHP (via node-wp-i18n), project JS, and@byteever/*packages; PHP i18n calls missing a domain get one added. - Extended dependency extraction for cross-plugin shared libraries.
Setup
eslint.config.js — only needed to declare the plugin's text domain, since byteever-scripts lint-js already falls back to the shared config when the project has none (the shared config wires up the ByteEver ESLint plugin from tools/eslint, extending @wordpress/eslint-plugin; the plugin object is a placeholder namespace for future byteever/* rules):
module.exports = [
...require( '@byteever/scripts/config/eslint.config' ),
{
rules: {
'@wordpress/i18n-text-domain': [
'error',
{ allowedTextDomain: 'my-plugin' },
],
},
},
];.prettierrc.js — @byteever/scripts depends on wp-prettier, the fork WordPress formatting needs, so a plugin never declares prettier itself:
module.exports = require( '@byteever/scripts/config/prettier.config' );{
"scripts": {
"start": "byteever-scripts start --experimental-modules --blocks-manifest",
"build": "byteever-scripts build --experimental-modules --blocks-manifest",
"lint:js": "byteever-scripts lint-js",
"lint:css": "byteever-scripts lint-style",
"format": "byteever-scripts format"
},
"byteever": {
"entries": {
"admin": "src/admin/index.js",
"frontend": "src/frontend/index.js"
}
}
}Options
Under the byteever key in package.json:
entries— entry points; a string path, or a webpack entry descriptor for producers exposing a shared library:
{
"byteever": {
"entries": {
"shared": {
"import": "src/shared/index.js",
"library": {
"name": [ "byteever", "shared" ],
"type": "window"
}
}
}
}
}externals— scoped packages consumed from another plugin's shared library; handles are written into.asset.phpas{scope}-{name}:
{
"byteever": {
"externals": {
"@byteever/shared": [ "byteever", "shared" ]
}
}
}i18n— text domain handling.textdomainis detected from the packagenamewhen not set;updateDomainslists the domains to replace (truefor all) and defaults to[ "byteever" ];include/excludetake directories or glob patterns — PHP files are selected internally:
{
"byteever": {
"i18n": {
"textdomain": "my-plugin",
"updateDomains": [ "byteever", "old-domain" ],
"include": [ "vendor/byteever" ],
"exclude": [ "vendor/byteever/tests" ]
}
}
}Custom webpack config
Create a webpack.config.js and byteever-scripts defers to it. Extend the ByteEver config exactly like the @wordpress/scripts one:
const baseConfig = require( '@byteever/scripts/config/webpack.config' );
module.exports = {
...baseConfig,
entry: {
...baseConfig.entry,
'js/admin': './src/js/admin.js',
},
};With --experimental-modules the export is a [ scripts, modules ] array, matching @wordpress/scripts.
Text domain
The target domain is detected from the package name, normalized to a slug; override it with byteever.i18n.textdomain. The domains to replace default to [ "byteever" ]; override with byteever.i18n.updateDomains (or true for all). Vendor PHP is rewritten in place via node-wp-i18n.
