Mahamudul Hasan Rubel
HomeBlogCoursesAboutProjectsSkillsExperiencePhotosContact
Mahamudul Hasan Rubel

Senior Software Engineer crafting high-performance web applications and SaaS platforms.

Navigation

  • Home
  • Blog
  • Courses
  • About
  • Projects
  • Skills
  • Experience
  • Photos
  • Contact

Get in Touch

Available for senior/lead roles and consulting.

bd.mhrubel@gmail.comHire Me

© 2026 Mahamudul Hasan Rubel. All rights reserved.

Built with using Next.js 16 & Tailwind v4

Back to Blog
Lesson 2 of the Intermediate WordPress Plugins: REST API & React Admin course
WordPressDevelopmentJune 25, 20263 min read

Introduction to @wordpress/scripts: Modern WordPress Builds

Master @wordpress/scripts to automate your WordPress development. Learn to configure package.json and build modern JavaScript with Webpack and Babel.

WordPressJavaScriptWebpackBabelnpmDevelopment Toolsphpplugin-development

Previously in this course, we covered Setting up the WordPress Development Environment, where we established our local workspace and plugin scaffolding. Now, we're ready to modernize our development workflow.

Writing raw, uncompiled JavaScript for WordPress is a recipe for maintenance headaches. As we prepare to build a React-based admin dashboard for our Knowledge Base plugin, we need a professional build pipeline. That is where @wordpress/scripts comes in.

Understanding the Build Pipeline

In the modern WordPress ecosystem, we don't ship source code directly to the browser. Instead, we use tools to transpile modern JavaScript (ESNext/JSX) into browser-compatible code.

@wordpress/scripts is a collection of reusable scripts maintained by the WordPress core team. It abstracts away the complexity of configuring Webpack and Babel.

  • Webpack handles the "bundling"—taking your modular JavaScript files and combining them into a single, optimized file.
  • Babel handles "transpilation"—converting modern syntax (like arrow functions or classes) into older versions of JavaScript that older browsers understand.

By using this package, you avoid the "configuration hell" that often plagues custom Webpack setups.

Setting Up Your Project

First, ensure you have Node.js installed. Open your terminal, navigate to your plugin directory, and initialize your package.json file:

Bash
npm init -y

Next, install the WordPress scripts package as a development dependency:

Bash
npm install @wordpress/scripts --save-dev

This command adds the necessary tools to your node_modules folder and updates your package.json. Now, open that file and update the scripts section to leverage the built-in commands:

JSON
{
  "scripts": {
    "build": "wp-scripts build",
    "start": "wp-scripts start"
  }
}

Building Your First Script

To see this in action, create a folder named src in your plugin root and add an index.js file:

JAVASCRIPT
// src/index.js
const greeting = "Hello from the build pipeline!";
console.log(greeting);

Now, run the build command in your terminal:

Bash
npm run build

@wordpress/scripts looks for src/index.js by default and outputs a bundled file into build/index.js. If you inspect build/index.js, you'll see your code wrapped in a Webpack runtime environment. This build/index.js is the file you will eventually enqueue in WordPress using the Enqueuing scripts and styles the correct way in WordPress guidelines.

Hands-on Exercise

  1. Add a second file in your src folder called utils.js and export a simple function: export const log = (msg) => console.log('Log: ' + msg);.
  2. Import this function into src/index.js and use it.
  3. Run npm run build again.
  4. Observe how Webpack automatically resolves the module dependency and bundles both files into one.

Common Pitfalls

  • Forgetting the build/ directory: Always add build/ to your .gitignore file. You should never commit your built assets to version control; only commit the source code.
  • Dependency Confusion: Ensure you are using npm install --save-dev for build tools. If you accidentally install them as production dependencies, your plugin will be unnecessarily bloated when you package it for distribution.
  • Enqueuing the wrong file: Beginners often try to enqueue the src/index.js file. Remember: the browser needs the compiled output in build/index.js.

By mastering these tools, you're setting the stage for the more complex React development we'll tackle later in this course. You now have a repeatable, professional environment for compiling your assets.

Up next: Configuring ESLint and Prettier to ensure our code quality remains high as our codebase grows.

Previous lessonSetting up the WordPress Development EnvironmentNext lesson Configuring ESLint and Prettier
Back to Blog

Similar Posts

WordPressJune 25, 20263 min read

Creating a React Form for Submissions in WordPress

Learn to build interactive React forms in WordPress using controlled components. Master state management and submission events for your admin dashboard.

Read more
WordPressJune 25, 20263 min read

Scaffolding the React Admin Dashboard for WordPress Plugins

Learn how to scaffold your React admin dashboard by registering a WordPress menu, creating a root container, and mounting your application into the DOM.

Part of the course

Intermediate WordPress Plugins: REST API & React Admin

intermediate · Lesson 2 of 45

  1. 1

    Setting up the WordPress Development Environment

    3 min
  2. 2

    Introduction to @wordpress/scripts

    3 min
  3. 3

    Configuring ESLint and Prettier

    3 min
Read more
WordPressReact DevelopmentJune 25, 20263 min read

Building the Knowledge Base Service Layer | WordPress REST API

Stop scattering fetch calls across your React components. Learn to build a clean service layer to centralize API logic and simplify your WordPress plugin.

Read more
  • 4

    Localizing Data for JavaScript

    3 min
  • 5

    Anatomy of a REST API Endpoint

    3 min
  • 6

    Implementing REST API Permission Callbacks

    3 min
  • 7

    Handling GET Requests in REST API

    3 min
  • 8

    Validating and Sanitizing API Arguments

    4 min
  • 9

    Creating POST Endpoints for Data Submission

    3 min
  • 10

    Updating Existing API Resources

    3 min
  • 11

    Handling Asynchronous State in React

    3 min
  • 12

    Building the Knowledge Base Service Layer

    3 min
  • 13

    Scaffolding the React Admin Dashboard

    3 min
  • 14

    Working with @wordpress/components

    3 min
  • 15

    Creating a React Form for Submissions

    3 min
  • 16

    Implementing CRUD in the Admin UI

    3 min
  • 17

    Understanding WordPress Data Store Architecture

    Coming soon
  • 18

    Registering a Custom Data Store

    Coming soon
  • 19

    Writing Selectors for Data Access

    Coming soon
  • 20

    Defining Actions and Reducers

    Coming soon
  • 21

    Implementing Resolvers for Data Fetching

    Coming soon
  • 22

    Optimizing Performance with Selectors

    Coming soon
  • 23

    Handling Complex State Dependencies

    Coming soon
  • 24

    Implementing Nonce Verification

    Coming soon
  • 25

    Advanced Sanitization Techniques

    Coming soon
  • 26

    Input Validation and Error Handling

    Coming soon
  • 27

    Protecting Admin Screens

    Coming soon
  • 28

    Production Build Pipeline

    Coming soon
  • 29

    Debugging React in the WordPress Admin

    Coming soon
  • 30

    Building Search and Filter Functionality

    Coming soon
  • 31

    Internationalization in React

    Coming soon
  • 32

    Managing File Uploads via REST API

    Coming soon
  • 33

    Optimizing API Response Times

    Coming soon
  • 34

    Working with Date and Time in React

    Coming soon
  • 35

    Implementing Drag-and-Drop Sorting

    Coming soon
  • 36

    Creating Custom Hooks for API Logic

    Coming soon
  • 37

    Integrating with Gutenberg Blocks

    Coming soon
  • 38

    Handling Conflict Resolution

    Coming soon
  • 39

    Building a Modal Confirmation System

    Coming soon
  • 40

    Implementing Activity Logging

    Coming soon
  • 41

    Using Webpack Aliases

    Coming soon
  • 42

    Unit Testing API Endpoints

    Coming soon
  • 43

    Unit Testing React Components

    Coming soon
  • 44

    Handling Large Datasets with GraphQL

    Coming soon
  • 45

    Implementing Real-time Updates with Web

    Coming soon
  • View full course