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

@artemsemkin/vite-plugin-wp-headers

v2.0.3

Published

Vite plugin for automatic WordPress header generation during build and dev

Readme

@artemsemkin/vite-plugin-wp-headers

Vite plugin that automates file generation during the build lifecycle. Runs a callback on every build start and re-runs it when watched files change during dev — no manual scripts, no forgotten rebuilds.

Install

npm install @artemsemkin/vite-plugin-wp-headers -D

Why

Build systems often need to generate or update files before bundling starts — WordPress header comments from package.json, version stamps, license blocks, etc. Without automation, you either forget to regenerate or add a manual pre-build step that breaks when someone skips it.

This plugin hooks into Vite's lifecycle so generation happens automatically:

  • On every vite build invocation
  • On dev server startup
  • On every change to watched source files during dev

You provide the generation logic. The plugin handles when it runs.

API

wpHeaders({
  generate(): void    // called on build start + file changes during dev
  watch?: string[]    // absolute paths to watch during dev server
}): Plugin

Examples

WordPress headers from package.json

Pair with @artemsemkin/wp-headers to generate style.css headers, plugin PHP headers, and readme.txt blocks from package.json data:

// vite.config.ts
import { resolve } from 'node:path'
import { processMapping } from '@artemsemkin/wp-headers'
import { wpHeaders } from '@artemsemkin/vite-plugin-wp-headers'

const themeDir = resolve(__dirname, 'themes/flavor')
const pluginDir = resolve(__dirname, 'plugins/flavor-core')

const mappings = [
  { type: 'theme', slug: 'flavor', entityDir: themeDir, tgmBasePath: resolve(themeDir, 'src/php') },
  { type: 'plugin', slug: 'flavor-core', entityDir: pluginDir, tgmBasePath: resolve(themeDir, 'src/php') },
]

export default {
  plugins: [
    wpHeaders({
      generate() {
        for (const m of mappings) {
          processMapping(m)
        }
      },
      watch: mappings.map((m) => resolve(m.entityDir, 'package.json')),
    }),
  ],
}

Change any package.json version field during dev → headers regenerate instantly.

Any file generation

Works with any generation logic — not limited to WordPress:

import { writeFileSync } from 'node:fs'
import { wpHeaders } from '@artemsemkin/vite-plugin-wp-headers'

export default {
  plugins: [
    wpHeaders({
      generate() {
        writeFileSync('src/version.ts', `export const VERSION = '${Date.now()}'`)
      },
    }),
  ],
}

Behavior

  • Build: generate() runs once during configResolved
  • Dev server: generate() runs on startup, then again whenever a watched file changes
  • Errors during dev are logged via Vite's logger (won't crash the server)