FazBrowse GitHub Viewer | Trending |
URL:
| Home
Tools: [Download Repo ZIP]   [Original HTTPS Page]

block-development-examples/plugins/basic-esnext-a2ab62 at trunk · WordPress/block-development-examples · GitHub

Latest commit

 

History

History

README.md

Basic Block with ESNext and Build Process

This example demonstrates how to create a modern WordPress block using ESNext (modern JavaScript) and JSX syntax. It showcases the fundamental setup required for block development with a build process powered by @wordpress/scripts, which handles all the necessary tooling configuration.

Key concepts covered:

  • Modern JavaScript (ESNext) and JSX syntax usage
  • Build process setup with @wordpress/scripts
  • Basic block registration and rendering
  • Static block implementation
  • NPM scripts for development and production builds
Example Description Tags Download .zip Live Demo
Basic ESNext Demonstrates how to create a basic block using modern JavaScript (ESNext) and JSX syntax with a build process powered by @wordpress/scripts. minimal 📦

Understanding the Example Code

Build Process

  1. Development Mode

    • Uses npm start for development
    • Provides hot reloading
    • Generates source maps for debugging
    • Watches for file changes
  2. Production Build

    • Uses npm run build for production
    • Optimizes and minifies code
    • Generates production-ready assets
    • Performs tree shaking

Block Implementation

  1. Block Registration

    • Block metadata defined in block.json
    • Registered using registerBlockType
    • Uses modern ESNext syntax for cleaner code
  2. Rendering

    • Static block implementation in save.js
    • Uses JSX for template rendering
    • Implements useBlockProps for block attributes

File Structure

src/
├── edit.js      # Block editor component
├── save.js      # Saved content component
├── style.scss   # Frontend & editor styles
├── editor.scss  # Editor-only styles
├── block.json   # Block metadata
└── index.js     # Block registration

Related Resources


Note Check the Start Guide for local development with the examples


Back | FazBrowse Home | New Git URL