{"_id":"@artemsemkin/vite-plugin-wp-headers","_rev":"6-662310b496f141269e9dbdbb7bf961bb","name":"@artemsemkin/vite-plugin-wp-headers","dist-tags":{"latest":"2.0.5"},"versions":{"1.0.0":{"name":"@artemsemkin/vite-plugin-wp-headers","version":"1.0.0","keywords":["vite","vite-plugin","wordpress","wp-headers"],"author":{"name":"Artem Semkin"},"license":"MIT","_id":"@artemsemkin/vite-plugin-wp-headers@1.0.0","maintainers":[{"name":"artemsemkin","email":"me@artemsemkin.com"}],"homepage":"https://github.com/artkrsk/vite-plugin-wp-headers#readme","bugs":{"url":"https://github.com/artkrsk/vite-plugin-wp-headers/issues"},"dist":{"shasum":"862c41d4d7aff3bcbded6fe968f2fa56de262fab","tarball":"https://registry.npmjs.org/@artemsemkin/vite-plugin-wp-headers/-/vite-plugin-wp-headers-1.0.0.tgz","fileCount":5,"integrity":"sha512-by+o1kPDxr9ewfD2YgST9NafL/WSafY2sHFrbDBpIiDHC3pe2C2ZpaCySFQKnZ9wh2ppRY9xa5BxosmDBkciLQ==","signatures":[{"sig":"MEQCIDI7RDHfvZzboUIsPxu5XVfFEb4QS8nnwxkDi1Iz/3cvAiAXIJPXACnDC9L39SanicJBmteGxYu9ZBBND7zmdBAqCw==","keyid":"SHA256:DhQ8wR5APBvFHLF/+Tc+AYvPOdTpcIDqOhxsBHRwC7U"}],"unpackedSize":4271},"type":"module","exports":{".":{"types":"./dist/index.d.ts","default":"./dist/index.js"}},"gitHead":"9039be3dad7ca5136d75e63678d9a559204e892b","scripts":{"build":"tsc -p tsconfig.build.json","prepublishOnly":"pnpm build"},"_npmUser":{"name":"artemsemkin","email":"me@artemsemkin.com"},"repository":{"url":"git+https://github.com/artkrsk/vite-plugin-wp-headers.git","type":"git"},"_npmVersion":"11.10.0","description":"Vite plugin for WordPress file header generation","directories":{},"_nodeVersion":"25.1.0","dependencies":{"@artemsemkin/wp-headers":"^1.1.0"},"publishConfig":{"access":"public"},"_hasShrinkwrap":false,"devDependencies":{"vite":"^7.0.0","typescript":"^5.7.0","@types/node":"^25.3.0"},"peerDependencies":{"vite":">=5"},"_npmOperationalInternal":{"tmp":"tmp/vite-plugin-wp-headers_1.0.0_1771563105866_0.009085342080025205","host":"s3://npm-registry-packages-npm-production"}},"2.0.0":{"name":"@artemsemkin/vite-plugin-wp-headers","version":"2.0.0","keywords":["vite","vite-plugin","wordpress","wp-headers"],"author":{"name":"Artem Semkin"},"license":"MIT","_id":"@artemsemkin/vite-plugin-wp-headers@2.0.0","maintainers":[{"name":"artemsemkin","email":"me@artemsemkin.com"}],"homepage":"https://github.com/artkrsk/vite-plugin-wp-headers#readme","bugs":{"url":"https://github.com/artkrsk/vite-plugin-wp-headers/issues"},"dist":{"shasum":"adbc46d7ba06d0556a2e945156be8c6f218d683c","tarball":"https://registry.npmjs.org/@artemsemkin/vite-plugin-wp-headers/-/vite-plugin-wp-headers-2.0.0.tgz","fileCount":5,"integrity":"sha512-cK0PqonkybZW4PUWzyROuaD0d5W0uDoRbsAnbbf6SZBak9LPLveGq+RvmpOqZtxAUs9hajVmYrn8sZib7LoyBA==","signatures":[{"sig":"MEYCIQDBg+ALL/xuWmnhIkbUW9kgGu+nN7WmnPms3PDl463Q5wIhAMK+i+XoVopCVw4xNso75k95Eqwgv5YZ8ytST11M8Zb2","keyid":"SHA256:DhQ8wR5APBvFHLF/+Tc+AYvPOdTpcIDqOhxsBHRwC7U"}],"unpackedSize":5072},"type":"module","exports":{".":{"types":"./dist/index.d.ts","default":"./dist/index.js"}},"gitHead":"3335946f63cc2e6dd9f158108f84c15d2702ae72","scripts":{"build":"tsc -p tsconfig.build.json","prepublishOnly":"pnpm build"},"_npmUser":{"name":"artemsemkin","email":"me@artemsemkin.com"},"repository":{"url":"git+https://github.com/artkrsk/vite-plugin-wp-headers.git","type":"git"},"_npmVersion":"11.10.0","description":"Vite plugin that calls a generate function on build start and watches files during dev","directories":{},"_nodeVersion":"25.1.0","publishConfig":{"access":"public"},"_hasShrinkwrap":false,"devDependencies":{"vite":"^7.0.0","typescript":"^5.7.0","@types/node":"^25.3.0"},"peerDependencies":{"vite":">=5"},"_npmOperationalInternal":{"tmp":"tmp/vite-plugin-wp-headers_2.0.0_1771564608816_0.5005079368386844","host":"s3://npm-registry-packages-npm-production"}},"2.0.2":{"name":"@artemsemkin/vite-plugin-wp-headers","version":"2.0.2","keywords":["vite","vite-plugin","wordpress","wp-headers"],"author":{"name":"Artem Semkin"},"license":"MIT","_id":"@artemsemkin/vite-plugin-wp-headers@2.0.2","maintainers":[{"name":"artemsemkin","email":"me@artemsemkin.com"}],"homepage":"https://github.com/artkrsk/vite-plugin-wp-headers#readme","bugs":{"url":"https://github.com/artkrsk/vite-plugin-wp-headers/issues"},"dist":{"shasum":"db78aef20ef81b0519feb85be370428fdf3b1f21","tarball":"https://registry.npmjs.org/@artemsemkin/vite-plugin-wp-headers/-/vite-plugin-wp-headers-2.0.2.tgz","fileCount":5,"integrity":"sha512-1YUX7Hm17e0+8APG16ZcyUp6D7V/JqaWwBGihdNOFbeYj6V3pXuK3JscSiC7KTS+5DjpFsXDSlxCALqVjl3DJg==","signatures":[{"sig":"MEYCIQDe2H8QdeX9eJpdeG8EIq0TzmXdKiKcrDFNPxlndLcjTAIhAMxLmJvvdrZWDKrsxevkfr4ZaKrQ5RT4Ai0C3L3j/KjP","keyid":"SHA256:DhQ8wR5APBvFHLF/+Tc+AYvPOdTpcIDqOhxsBHRwC7U"}],"unpackedSize":5945},"type":"module","exports":{".":{"types":"./dist/index.d.ts","default":"./dist/index.js"}},"gitHead":"503a5235512091f5d999e2f044f4960a1358d4aa","scripts":{"build":"tsc -p tsconfig.build.json","prepublishOnly":"pnpm build"},"_npmUser":{"name":"artemsemkin","email":"me@artemsemkin.com"},"repository":{"url":"git+https://github.com/artkrsk/vite-plugin-wp-headers.git","type":"git"},"_npmVersion":"11.10.0","description":"Vite plugin for automatic WordPress header generation during build and dev","directories":{},"_nodeVersion":"25.1.0","publishConfig":{"access":"public"},"_hasShrinkwrap":false,"devDependencies":{"vite":"^7.0.0","typescript":"^5.7.0","@types/node":"^25.3.0"},"peerDependencies":{"vite":">=5"},"_npmOperationalInternal":{"tmp":"tmp/vite-plugin-wp-headers_2.0.2_1771565172303_0.09543752338452816","host":"s3://npm-registry-packages-npm-production"}},"2.0.3":{"name":"@artemsemkin/vite-plugin-wp-headers","version":"2.0.3","keywords":["vite","vite-plugin","wordpress","wp-headers"],"author":{"name":"Artem Semkin"},"license":"MIT","_id":"@artemsemkin/vite-plugin-wp-headers@2.0.3","maintainers":[{"name":"artemsemkin","email":"me@artemsemkin.com"}],"homepage":"https://github.com/artkrsk/vite-plugin-wp-headers#readme","bugs":{"url":"https://github.com/artkrsk/vite-plugin-wp-headers/issues"},"dist":{"shasum":"0a94a7c79139af83d5002d651ad13325609b1b88","tarball":"https://registry.npmjs.org/@artemsemkin/vite-plugin-wp-headers/-/vite-plugin-wp-headers-2.0.3.tgz","fileCount":5,"integrity":"sha512-f1swoxbMfGUY/vUAM1XJkoN72WIAgLZKQyfx6z0ex8VR/MrHyE+nWsk3ceZzoKd2qzvI3gvB6ueekbljcpmRwA==","signatures":[{"sig":"MEYCIQCueaAeJZ141X9aLe8eGT0hOg9bwBNZDhNZwFOng5FQqwIhANug0B1Xkh2ArQuCcdxsVevk8Hzx6SO/4qfJiWR5AHPc","keyid":"SHA256:DhQ8wR5APBvFHLF/+Tc+AYvPOdTpcIDqOhxsBHRwC7U"}],"attestations":{"url":"https://registry.npmjs.org/-/npm/v1/attestations/@artemsemkin%2fvite-plugin-wp-headers@2.0.3","provenance":{"predicateType":"https://slsa.dev/provenance/v1"}},"unpackedSize":5981},"type":"module","exports":{".":{"types":"./dist/index.d.ts","default":"./dist/index.js"}},"gitHead":"bab91c17cafd82371b87644be77a7d9bb4f4c193","scripts":{"build":"tsc -p tsconfig.build.json","prepublishOnly":"pnpm build"},"_npmUser":{"name":"GitHub Actions","email":"npm-oidc-no-reply@github.com","trustedPublisher":{"id":"github","oidcConfigId":"oidc:089fff55-7afb-4390-a41a-239fcbcdc4cb"}},"repository":{"url":"git+https://github.com/artkrsk/vite-plugin-wp-headers.git","type":"git"},"_npmVersion":"11.10.1","description":"Vite plugin for automatic WordPress header generation during build and dev","directories":{},"_nodeVersion":"22.22.0","publishConfig":{"access":"public"},"_hasShrinkwrap":false,"packageManager":"pnpm@10.30.0","devDependencies":{"vite":"^7.0.0","typescript":"^5.7.0","@types/node":"^25.3.0"},"peerDependencies":{"vite":">=5"},"_npmOperationalInternal":{"tmp":"tmp/vite-plugin-wp-headers_2.0.3_1771672178678_0.3832463020726815","host":"s3://npm-registry-packages-npm-production"}},"2.0.4":{"name":"@artemsemkin/vite-plugin-wp-headers","version":"2.0.4","keywords":["vite","vite-plugin","wordpress","wp-headers"],"author":{"name":"Artem Semkin"},"license":"MIT","_id":"@artemsemkin/vite-plugin-wp-headers@2.0.4","maintainers":[{"name":"artemsemkin","email":"me@artemsemkin.com"}],"homepage":"https://github.com/artkrsk/vite-plugin-wp-headers#readme","bugs":{"url":"https://github.com/artkrsk/vite-plugin-wp-headers/issues"},"dist":{"shasum":"d168197159de67985c94fd94bce9b11cb1be65af","tarball":"https://registry.npmjs.org/@artemsemkin/vite-plugin-wp-headers/-/vite-plugin-wp-headers-2.0.4.tgz","fileCount":5,"integrity":"sha512-Oes93lX8LCk2y7DxMK6ns0vBv2TY4gmyBeNEyURBxwqYCMFLbm9NzqCTrH3XwkajqlQ88WmCKJflJVbxJcOKZA==","signatures":[{"sig":"MEQCIG+cZFpls7VE8dHI1MulAhYjUrLeEmllmo+DflEwBypsAiBICjbB6MOfXV7A0d5tPVNn4gcbyUaXNlGNR3oBqd3WLQ==","keyid":"SHA256:DhQ8wR5APBvFHLF/+Tc+AYvPOdTpcIDqOhxsBHRwC7U"}],"attestations":{"url":"https://registry.npmjs.org/-/npm/v1/attestations/@artemsemkin%2fvite-plugin-wp-headers@2.0.4","provenance":{"predicateType":"https://slsa.dev/provenance/v1"}},"unpackedSize":5981},"type":"module","exports":{".":{"types":"./dist/index.d.ts","default":"./dist/index.js"}},"gitHead":"587d6f9cbdf5cf6c17fc122d1d225b545808778b","scripts":{"build":"tsc -p tsconfig.build.json","prepublishOnly":"pnpm build"},"_npmUser":{"name":"GitHub Actions","email":"npm-oidc-no-reply@github.com","trustedPublisher":{"id":"github","oidcConfigId":"oidc:089fff55-7afb-4390-a41a-239fcbcdc4cb"}},"repository":{"url":"git+https://github.com/artkrsk/vite-plugin-wp-headers.git","type":"git"},"_npmVersion":"11.9.0","description":"Vite plugin for automatic WordPress header generation during build and dev","directories":{},"_nodeVersion":"24.14.0","publishConfig":{"access":"public"},"_hasShrinkwrap":false,"packageManager":"pnpm@10.30.0","devDependencies":{"vite":"^7.0.0","typescript":"^5.7.0","@types/node":"^25.3.0"},"peerDependencies":{"vite":">=5"},"_npmOperationalInternal":{"tmp":"tmp/vite-plugin-wp-headers_2.0.4_1774088448142_0.7251934174521528","host":"s3://npm-registry-packages-npm-production"}},"2.0.5":{"name":"@artemsemkin/vite-plugin-wp-headers","version":"2.0.5","description":"Vite plugin for automatic WordPress header generation during build and dev","license":"MIT","author":{"name":"Artem Semkin"},"repository":{"type":"git","url":"git+https://github.com/artkrsk/vite-plugin-wp-headers.git"},"homepage":"https://github.com/artkrsk/vite-plugin-wp-headers#readme","bugs":{"url":"https://github.com/artkrsk/vite-plugin-wp-headers/issues"},"keywords":["vite","vite-plugin","wordpress","wp-headers"],"type":"module","exports":{".":{"types":"./dist/index.d.ts","default":"./dist/index.js"}},"publishConfig":{"access":"public"},"scripts":{"build":"tsc -p tsconfig.build.json","prepublishOnly":"pnpm build"},"peerDependencies":{"vite":">=5"},"devDependencies":{"@types/node":"^25.3.0","typescript":"^5.7.0","vite":"^7.0.0"},"packageManager":"pnpm@10.30.0","gitHead":"b4ef4f78b2716dd50c9f4ebe9bc28c3babd306fc","_id":"@artemsemkin/vite-plugin-wp-headers@2.0.5","_nodeVersion":"24.18.0","_npmVersion":"11.16.0","dist":{"integrity":"sha512-u1MahubVDM7psAPJSAY7VI3fhllL/jMOUMgCVk1C1PDb8Y6EmTaRTnQSx2ACotvtHk3D/2ENkd4oOIJssPMhrg==","shasum":"317b9e687f54510617cff6263bd06f6d6247c013","tarball":"https://registry.npmjs.org/@artemsemkin/vite-plugin-wp-headers/-/vite-plugin-wp-headers-2.0.5.tgz","fileCount":5,"unpackedSize":6000,"attestations":{"url":"https://registry.npmjs.org/-/npm/v1/attestations/@artemsemkin%2fvite-plugin-wp-headers@2.0.5","provenance":{"predicateType":"https://slsa.dev/provenance/v1"}},"signatures":[{"keyid":"SHA256:DhQ8wR5APBvFHLF/+Tc+AYvPOdTpcIDqOhxsBHRwC7U","sig":"MEUCIAMm2egUXYDH8MDx9iQjKMWIqxuG8SYBx31zF0/YCFyoAiEA3MSwzWBgA/drmpEe9wkrUF2wFtRy/DN2ue1unpma598="}]},"_npmUser":{"name":"GitHub Actions","email":"npm-oidc-no-reply@github.com","trustedPublisher":{"id":"github","oidcConfigId":"oidc:089fff55-7afb-4390-a41a-239fcbcdc4cb"}},"directories":{},"maintainers":[{"name":"artemsemkin","email":"me@artemsemkin.com"}],"_npmOperationalInternal":{"host":"s3://npm-registry-packages-npm-production","tmp":"tmp/vite-plugin-wp-headers_2.0.5_1784909996797_0.34746876968552765"},"_hasShrinkwrap":false}},"time":{"created":"2026-02-20T04:51:45.745Z","modified":"2026-07-24T16:19:57.340Z","1.0.0":"2026-02-20T04:51:46.016Z","2.0.0":"2026-02-20T05:16:48.978Z","2.0.2":"2026-02-20T05:26:12.479Z","2.0.3":"2026-02-21T11:09:38.829Z","2.0.4":"2026-03-21T10:20:48.297Z","2.0.5":"2026-07-24T16:19:56.937Z"},"bugs":{"url":"https://github.com/artkrsk/vite-plugin-wp-headers/issues"},"author":{"name":"Artem Semkin"},"license":"MIT","homepage":"https://github.com/artkrsk/vite-plugin-wp-headers#readme","keywords":["vite","vite-plugin","wordpress","wp-headers"],"repository":{"type":"git","url":"git+https://github.com/artkrsk/vite-plugin-wp-headers.git"},"description":"Vite plugin for automatic WordPress header generation during build and dev","maintainers":[{"name":"artemsemkin","email":"me@artemsemkin.com"}],"readme":"# @artemsemkin/vite-plugin-wp-headers\n\nVite 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.\n\n## Install\n\n```bash\nnpm install @artemsemkin/vite-plugin-wp-headers -D\n```\n\n## Why\n\nBuild 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.\n\nThis plugin hooks into Vite's lifecycle so generation happens automatically:\n- On every `vite build` invocation\n- On dev server startup\n- On every change to watched source files during dev\n\nYou provide the generation logic. The plugin handles when it runs.\n\n## API\n\n```ts\nwpHeaders({\n  generate(): void    // called on build start + file changes during dev\n  watch?: string[]    // absolute paths to watch during dev server\n}): Plugin\n```\n\n## Examples\n\n### WordPress headers from `package.json`\n\nPair with [`@artemsemkin/wp-headers`](https://www.npmjs.com/package/@artemsemkin/wp-headers) to generate `style.css` headers, plugin PHP headers, and `readme.txt` blocks from `package.json` data:\n\n```ts\n// vite.config.ts\nimport { resolve } from 'node:path'\nimport { processMapping } from '@artemsemkin/wp-headers'\nimport { wpHeaders } from '@artemsemkin/vite-plugin-wp-headers'\n\nconst themeDir = resolve(__dirname, 'themes/flavor')\nconst pluginDir = resolve(__dirname, 'plugins/flavor-core')\n\nconst mappings = [\n  { type: 'theme', slug: 'flavor', entityDir: themeDir, tgmBasePath: resolve(themeDir, 'src/php') },\n  { type: 'plugin', slug: 'flavor-core', entityDir: pluginDir, tgmBasePath: resolve(themeDir, 'src/php') },\n]\n\nexport default {\n  plugins: [\n    wpHeaders({\n      generate() {\n        for (const m of mappings) {\n          processMapping(m)\n        }\n      },\n      watch: mappings.map((m) => resolve(m.entityDir, 'package.json')),\n    }),\n  ],\n}\n```\n\nChange any `package.json` version field during dev → headers regenerate instantly.\n\n### Any file generation\n\nWorks with any generation logic — not limited to WordPress:\n\n```ts\nimport { writeFileSync } from 'node:fs'\nimport { wpHeaders } from '@artemsemkin/vite-plugin-wp-headers'\n\nexport default {\n  plugins: [\n    wpHeaders({\n      generate() {\n        writeFileSync('src/version.ts', `export const VERSION = '${Date.now()}'`)\n      },\n    }),\n  ],\n}\n```\n\n## Behavior\n\n- **Build**: `generate()` runs once during `configResolved`\n- **Dev server**: `generate()` runs on startup, then again whenever a watched file changes\n- Errors during dev are logged via Vite's logger (won't crash the server)\n","readmeFilename":"README.md"}