@iservice-dev/is-wp-plugin-kit 1.6.3 → 1.6.5
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/README.md +58 -72
- package/package.json +1 -1
- package/vite/index.js +8 -1
package/README.md
CHANGED
|
@@ -2,113 +2,99 @@
|
|
|
2
2
|
|
|
3
3
|
A toolkit for WordPress plugin development with Vite, TypeScript, and modern build tools.
|
|
4
4
|
|
|
5
|
-
##
|
|
5
|
+
## Quick Start
|
|
6
6
|
|
|
7
|
-
|
|
8
|
-
- 📦 **TypeScript Support**: Full TypeScript configuration for WordPress plugins
|
|
9
|
-
- 🎨 **SCSS Processing**: Modern CSS workflow with PostCSS and Autoprefixer
|
|
10
|
-
- 🔍 **Linting**: Pre-configured OXLint and Stylelint rules
|
|
11
|
-
- 🌍 **i18n Support**: Compile `.po` files to `.mo` for WordPress localization
|
|
12
|
-
- 📁 **Smart Asset Handling**: Automatic processing of JS, CSS, images, and fonts
|
|
13
|
-
|
|
14
|
-
## Installation
|
|
7
|
+
### 1. Initialize a New Plugin
|
|
15
8
|
|
|
16
9
|
```bash
|
|
17
|
-
|
|
10
|
+
npx @iservice-dev/is-wp-plugin-kit init
|
|
18
11
|
```
|
|
19
12
|
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
13
|
+
This sets up your complete plugin structure with:
|
|
14
|
+
- Configuration files (`.gitignore`, TypeScript, linting, PostCSS)
|
|
15
|
+
- Folder structure (`assets/`, `includes/`, `languages/`)
|
|
16
|
+
- Template files (`Config.php`, `Plugin.php`, `de_DE.po`)
|
|
17
|
+
- `vite.config.ts` with default settings
|
|
23
18
|
|
|
24
|
-
|
|
19
|
+
### 2. Install Dependencies
|
|
25
20
|
|
|
26
21
|
```bash
|
|
27
|
-
|
|
22
|
+
npm install
|
|
28
23
|
```
|
|
29
24
|
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
- `tsconfig.json` - TypeScript configuration optimized for WordPress
|
|
25
|
+
### 3. Start Development
|
|
26
|
+
|
|
27
|
+
```bash
|
|
28
|
+
npm run dev
|
|
29
|
+
```
|
|
36
30
|
|
|
37
|
-
|
|
31
|
+
## Configuration
|
|
38
32
|
|
|
39
|
-
|
|
33
|
+
### Port Settings
|
|
40
34
|
|
|
41
|
-
|
|
42
|
-
import { defineConfig } from 'vite';
|
|
43
|
-
import wpPluginKit from '@iservice-dev/is-wp-plugin-kit';
|
|
35
|
+
If you need a different port for general development, update both:
|
|
44
36
|
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
outDir: 'dist', // Output directory
|
|
50
|
-
})
|
|
51
|
-
]
|
|
37
|
+
**`vite.config.ts`:**
|
|
38
|
+
```typescript
|
|
39
|
+
export default wpPluginKitVite({
|
|
40
|
+
port: 5500 // Change this
|
|
52
41
|
});
|
|
53
42
|
```
|
|
54
43
|
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
```bash
|
|
60
|
-
npx is-wp-plugin-kit compile-mo
|
|
44
|
+
**`includes/lib/Core/Config.php`:**
|
|
45
|
+
```php
|
|
46
|
+
$this->vitePort = 5500; // Change this
|
|
61
47
|
```
|
|
62
48
|
|
|
63
|
-
|
|
49
|
+
### PHP Customization
|
|
64
50
|
|
|
65
|
-
|
|
51
|
+
All customization points in the PHP template files are marked with `TODO` comments. Check:
|
|
52
|
+
- `includes/lib/Core/Plugin.php`
|
|
53
|
+
- `includes/lib/Core/Config.php`
|
|
66
54
|
|
|
67
|
-
|
|
55
|
+
## Available Commands
|
|
68
56
|
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
- **WordPress-specific optimizations**
|
|
74
|
-
|
|
75
|
-
### Configuration Files
|
|
76
|
-
|
|
77
|
-
#### TypeScript (`tsconfig.json`)
|
|
78
|
-
Pre-configured for WordPress development with proper types and module resolution.
|
|
57
|
+
```bash
|
|
58
|
+
npm run dev # Development mode with watchers
|
|
59
|
+
npm run build # Production build
|
|
60
|
+
```
|
|
79
61
|
|
|
80
|
-
|
|
81
|
-
Includes Autoprefixer for automatic vendor prefixing.
|
|
62
|
+
## What's Included
|
|
82
63
|
|
|
83
|
-
|
|
84
|
-
- **
|
|
85
|
-
- **
|
|
64
|
+
- **Vite**: Fast development server with HMR
|
|
65
|
+
- **TypeScript**: Full type support for WordPress development
|
|
66
|
+
- **SCSS**: Modern CSS workflow with PostCSS and Autoprefixer
|
|
67
|
+
- **Linting**: OXLint for JS/TS, Stylelint for CSS/SCSS
|
|
68
|
+
- **i18n**: Automatic `.po` to `.mo` compilation
|
|
69
|
+
- **File Watchers**: Auto-lint and compile on file changes
|
|
86
70
|
|
|
87
71
|
## Project Structure
|
|
88
72
|
|
|
89
|
-
Your WordPress plugin should follow this structure:
|
|
90
|
-
|
|
91
73
|
```
|
|
92
74
|
your-plugin/
|
|
93
|
-
├──
|
|
94
|
-
│ ├──
|
|
95
|
-
│ ├──
|
|
96
|
-
│
|
|
97
|
-
├──
|
|
98
|
-
├──
|
|
99
|
-
├──
|
|
100
|
-
└──
|
|
75
|
+
├── assets/
|
|
76
|
+
│ ├── src/
|
|
77
|
+
│ │ ├── ts/ # TypeScript files
|
|
78
|
+
│ │ ├── scss/ # SCSS files
|
|
79
|
+
│ │ ├── images/ # Images
|
|
80
|
+
│ │ ├── fonts/ # Fonts
|
|
81
|
+
│ │ ├── l10n/ # Translation files (.po)
|
|
82
|
+
│ │ └── legacy/ # Legacy JS/CSS
|
|
83
|
+
│ └── dist/ # Built files (auto-generated)
|
|
84
|
+
├── includes/
|
|
85
|
+
│ └── lib/
|
|
86
|
+
│ ├── Core/ # Plugin core classes
|
|
87
|
+
│ ├── Admin/ # Admin classes
|
|
88
|
+
│ └── Frontend/ # Frontend classes
|
|
89
|
+
├── languages/ # Compiled .mo files
|
|
90
|
+
└── vite.config.ts
|
|
101
91
|
```
|
|
102
92
|
|
|
103
93
|
## Requirements
|
|
104
94
|
|
|
105
95
|
- Node.js 18 or higher
|
|
106
|
-
- Vite
|
|
96
|
+
- Vite 7.x
|
|
107
97
|
|
|
108
98
|
## License
|
|
109
99
|
|
|
110
100
|
ISC
|
|
111
|
-
|
|
112
|
-
## Repository
|
|
113
|
-
|
|
114
|
-
[https://github.com/iservice-dev/is-wp-plugin-kit](https://github.com/iservice-dev/is-wp-plugin-kit)
|
package/package.json
CHANGED
package/vite/index.js
CHANGED
|
@@ -43,6 +43,13 @@ export function wpPluginKitVite(userOptions = {}) {
|
|
|
43
43
|
{ src: "assets/src/legacy/js/*.js", dest: "js" },
|
|
44
44
|
];
|
|
45
45
|
|
|
46
|
+
// Filter out targets where source path doesn't exist or has no files
|
|
47
|
+
const cwd = userOptions.cwd ?? process.cwd();
|
|
48
|
+
const validTargets = staticCopyTargets.filter((target) => {
|
|
49
|
+
const files = fg.sync(target.src, { cwd });
|
|
50
|
+
return files.length > 0;
|
|
51
|
+
});
|
|
52
|
+
|
|
46
53
|
return defineConfig({
|
|
47
54
|
base: "./",
|
|
48
55
|
|
|
@@ -94,7 +101,7 @@ export function wpPluginKitVite(userOptions = {}) {
|
|
|
94
101
|
|
|
95
102
|
css: { postcss: "./postcss.config.cjs" },
|
|
96
103
|
|
|
97
|
-
plugins: [viteStaticCopy({ targets:
|
|
104
|
+
plugins: [viteStaticCopy({ targets: validTargets })],
|
|
98
105
|
|
|
99
106
|
...userOptions,
|
|
100
107
|
});
|