@artemsemkin/vite-plugin-wp-headers 1.0.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/LICENSE ADDED
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2026 Artem Semkin
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
package/README.md ADDED
@@ -0,0 +1,31 @@
1
+ # @artemsemkin/vite-plugin-wp-headers
2
+
3
+ Vite plugin that generates WordPress file headers from `package.json` data. Wraps [`@artemsemkin/wp-headers`](https://github.com/artkrsk/wp-headers).
4
+
5
+ ## Install
6
+
7
+ ```bash
8
+ npm install @artemsemkin/vite-plugin-wp-headers -D
9
+ ```
10
+
11
+ ## Usage
12
+
13
+ ```ts
14
+ // vite.config.ts
15
+ import { wpHeaders } from '@artemsemkin/vite-plugin-wp-headers'
16
+
17
+ export default {
18
+ plugins: [
19
+ wpHeaders([
20
+ {
21
+ type: 'theme',
22
+ slug: 'my-theme',
23
+ entityDir: 'themes/my-theme',
24
+ tgmBasePath: 'themes/my-theme/src/php',
25
+ },
26
+ ]),
27
+ ],
28
+ }
29
+ ```
30
+
31
+ Runs on `configResolved` (build + dev) and watches `package.json` changes during dev.
@@ -0,0 +1,8 @@
1
+ import type { Plugin } from 'vite';
2
+ import type { HeaderMapping } from '@artemsemkin/wp-headers';
3
+ export type { HeaderMapping };
4
+ /**
5
+ * Vite plugin that generates WordPress file headers (style.css, plugin PHP)
6
+ * and patches TGM version entries on build and during dev server.
7
+ */
8
+ export declare function wpHeaders(mappings: HeaderMapping[]): Plugin;
package/dist/index.js ADDED
@@ -0,0 +1,33 @@
1
+ import { resolve } from 'node:path';
2
+ import { processMapping } from '@artemsemkin/wp-headers';
3
+ /**
4
+ * Vite plugin that generates WordPress file headers (style.css, plugin PHP)
5
+ * and patches TGM version entries on build and during dev server.
6
+ */
7
+ export function wpHeaders(mappings) {
8
+ return {
9
+ name: 'vite-plugin-wp-headers',
10
+ configResolved() {
11
+ for (const mapping of mappings) {
12
+ processMapping(mapping);
13
+ }
14
+ },
15
+ configureServer(server) {
16
+ for (const mapping of mappings) {
17
+ const pkgPath = resolve(mapping.entityDir, 'package.json');
18
+ server.watcher.add(pkgPath);
19
+ server.watcher.on('change', (filePath) => {
20
+ if (filePath !== pkgPath) {
21
+ return;
22
+ }
23
+ try {
24
+ processMapping(mapping);
25
+ }
26
+ catch (err) {
27
+ server.config.logger.error(String(err));
28
+ }
29
+ });
30
+ }
31
+ },
32
+ };
33
+ }
package/package.json ADDED
@@ -0,0 +1,49 @@
1
+ {
2
+ "name": "@artemsemkin/vite-plugin-wp-headers",
3
+ "version": "1.0.0",
4
+ "description": "Vite plugin for WordPress file header generation",
5
+ "license": "MIT",
6
+ "author": "Artem Semkin",
7
+ "repository": {
8
+ "type": "git",
9
+ "url": "https://github.com/artkrsk/vite-plugin-wp-headers.git"
10
+ },
11
+ "homepage": "https://github.com/artkrsk/vite-plugin-wp-headers#readme",
12
+ "bugs": {
13
+ "url": "https://github.com/artkrsk/vite-plugin-wp-headers/issues"
14
+ },
15
+ "keywords": [
16
+ "vite",
17
+ "vite-plugin",
18
+ "wordpress",
19
+ "wp-headers"
20
+ ],
21
+ "type": "module",
22
+ "exports": {
23
+ ".": {
24
+ "types": "./dist/index.d.ts",
25
+ "default": "./dist/index.js"
26
+ }
27
+ },
28
+ "files": [
29
+ "dist"
30
+ ],
31
+ "publishConfig": {
32
+ "access": "public"
33
+ },
34
+ "scripts": {
35
+ "build": "tsc -p tsconfig.build.json",
36
+ "prepublishOnly": "pnpm build"
37
+ },
38
+ "dependencies": {
39
+ "@artemsemkin/wp-headers": "^1.1.0"
40
+ },
41
+ "peerDependencies": {
42
+ "vite": ">=5"
43
+ },
44
+ "devDependencies": {
45
+ "@types/node": "^25.3.0",
46
+ "typescript": "^5.7.0",
47
+ "vite": "^7.0.0"
48
+ }
49
+ }