npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2026 – Pkg Stats / Ryan Hefner

create-wp-component

v1.0.2

Published

CLI tool to scaffold WordPress components compatible with vite-plugin-wp-component

Readme

create-wp-component

A CLI scaffolding tool for quickly setting up a WordPress component project powered by vite-plugin-wp-component.
This tool generates the project boilerplate with: - Pre-configured Vite and PostCSS settings.

  • A ready-to-use index.html with the correct rootID injected.
  • An empty .env for FTP credentials.
  • Built-in npm scripts that map to vite-plugin-wp-component commands.

Installation

You can create a new project using npm or npx:

npx create-wp-component
cd my-component
npm install

Available Scripts

The CLI automatically registers the following scripts in package.json:

  • npm run config → Runs wp-component config (edit .env or component.config.json).
  • npm run build → Runs vite build and wp-component build (bundles your project and generates the plugin PHP file in one step).
  • npm run deploy → Runs wp-component deploy (deploys via FTP to your WordPress site).

Project Structure

A newly scaffolded project has the following structure:

Project/
├──index.html				// Preconfigured with __COMPONENT_CONFIG__.rootID
└── src/
	├── assets/				// Directory for external/static files
	│   └── javascript.webp
	├── generator.js		// Core component logic
	├── info.json			// Data consumed by generator (can be local or fetched remotely)
	├── main.js				// Entry point, mounts the component into the rootID
	├── styles.module.css	// CSS Modules stylesheet
	└── template.js			// Example of importing assets & styles

Key Files

  • main.js
    Accesses __COMPONENT_CONFIG__.rootID and renders your component inside the root element.

  • styles.module.css
    Uses CSS Modules to ensure class encapsulation and isolation.
    Class names follow this structure:

    [componentName]__[local]___[hash:base64:5]

    They are automatically transformed from class-css to classCss, so you can import them in JavaScript as:

    import styles from "./styles.module.css";
    element.className = styles.classCss;
  • generator.js
    Contains the core logic of the component, which is invoked from main.js.

  • info.json
    Provides configuration or data for generator.js.
    This can be a static file or dynamically fetched from an external server.

  • template.js
    Demonstrates how to import assets from /assets and styles from styles.module.css.


Typical Workflow

  1. Configure FTP credentials and metadata:

    npm run config
  2. Build the bundle and generate the WordPress plugin PHP:

    npm run build
  3. Deploy the plugin directly to WordPress:

    npm run deploy

Notes

  • The scaffold ensures that the same rootID is used across development and production (in sync with vite-plugin-wp-component).
  • CSS Modules are essential for encapsulation — no class name collisions with WordPress themes or other plugins.