create-wordpress-theme-ts 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 +21 -0
- package/README.md +249 -0
- package/bin/index.js +179 -0
- package/package.json +43 -0
- package/template/.eslintignore +2 -0
- package/template/.eslintrc.json +34 -0
- package/template/.prettierrc +7 -0
- package/template/index.html +21 -0
- package/template/package-lock.json +6323 -0
- package/template/package.json +48 -0
- package/template/php/functions.php +34 -0
- package/template/php/index.php +17 -0
- package/template/public/images/README.md +8 -0
- package/template/public/style.css +48 -0
- package/template/src/App.tsx +19 -0
- package/template/src/components/Layout.tsx +88 -0
- package/template/src/index.tsx +15 -0
- package/template/src/pages/About.tsx +66 -0
- package/template/src/pages/Home.tsx +133 -0
- package/template/src/pages/NotFound.tsx +57 -0
- package/template/src/styles/global.css +90 -0
- package/template/src/vite-env.d.ts +7 -0
- package/template/tsconfig.json +20 -0
- package/template/vite.config.ts +109 -0
|
@@ -0,0 +1,109 @@
|
|
|
1
|
+
import { defineConfig, loadEnv } from 'vite';
|
|
2
|
+
import react from '@vitejs/plugin-react';
|
|
3
|
+
import eslint from 'vite-plugin-eslint';
|
|
4
|
+
import { viteStaticCopy } from 'vite-plugin-static-copy';
|
|
5
|
+
import zipPack from 'vite-plugin-zip-pack';
|
|
6
|
+
|
|
7
|
+
/**
|
|
8
|
+
* Vite Configuration for WordPress React Theme
|
|
9
|
+
*/
|
|
10
|
+
export default defineConfig(({ mode }) => {
|
|
11
|
+
// Load env file based on `mode` (.env, .env.development, .env.production)
|
|
12
|
+
const env = loadEnv(mode, process.cwd(), '');
|
|
13
|
+
|
|
14
|
+
return {
|
|
15
|
+
// ========================================
|
|
16
|
+
// PLUGINS
|
|
17
|
+
// ========================================
|
|
18
|
+
plugins: [
|
|
19
|
+
// React support with Fast Refresh for HMR
|
|
20
|
+
react(),
|
|
21
|
+
|
|
22
|
+
// ESLint integration - shows lint errors in terminal during dev
|
|
23
|
+
eslint({
|
|
24
|
+
failOnError: false,
|
|
25
|
+
failOnWarning: false,
|
|
26
|
+
}),
|
|
27
|
+
|
|
28
|
+
// Copy static files to dist
|
|
29
|
+
// - PHP files for WordPress theme
|
|
30
|
+
// - WordPress theme style.css (with required header)
|
|
31
|
+
// - Images from public folder
|
|
32
|
+
viteStaticCopy({
|
|
33
|
+
targets: [
|
|
34
|
+
{
|
|
35
|
+
src: 'php/*',
|
|
36
|
+
dest: '',
|
|
37
|
+
},
|
|
38
|
+
{
|
|
39
|
+
src: 'public/style.css',
|
|
40
|
+
dest: '',
|
|
41
|
+
},
|
|
42
|
+
{
|
|
43
|
+
src: 'public/images/*',
|
|
44
|
+
dest: 'images',
|
|
45
|
+
},
|
|
46
|
+
],
|
|
47
|
+
}),
|
|
48
|
+
|
|
49
|
+
// Create WordPress theme zip after build
|
|
50
|
+
zipPack({
|
|
51
|
+
inDir: 'dist',
|
|
52
|
+
outDir: 'dist',
|
|
53
|
+
outFileName: 'wordpress-custom-theme.zip',
|
|
54
|
+
}),
|
|
55
|
+
],
|
|
56
|
+
|
|
57
|
+
// Static assets directory (favicon, images, etc.)
|
|
58
|
+
publicDir: 'public',
|
|
59
|
+
|
|
60
|
+
// ========================================
|
|
61
|
+
// BUILD OPTIONS
|
|
62
|
+
// ========================================
|
|
63
|
+
build: {
|
|
64
|
+
outDir: 'dist',
|
|
65
|
+
emptyOutDir: true,
|
|
66
|
+
|
|
67
|
+
// Source maps: inline for dev debugging, disabled for production
|
|
68
|
+
sourcemap: mode === 'development' ? 'inline' : false,
|
|
69
|
+
|
|
70
|
+
// Target modern browsers
|
|
71
|
+
target: 'esnext',
|
|
72
|
+
|
|
73
|
+
// Rollup output configuration
|
|
74
|
+
rollupOptions: {
|
|
75
|
+
output: {
|
|
76
|
+
// Fixed filenames for WordPress compatibility (no hashes)
|
|
77
|
+
// WordPress functions.php expects bundle.js and bundle.css
|
|
78
|
+
// style.css is reserved for WordPress theme header
|
|
79
|
+
entryFileNames: 'bundle.js',
|
|
80
|
+
chunkFileNames: '[name].js',
|
|
81
|
+
assetFileNames: (assetInfo) => {
|
|
82
|
+
if (assetInfo.name?.endsWith('.css')) {
|
|
83
|
+
return 'bundle.css';
|
|
84
|
+
}
|
|
85
|
+
return 'assets/[name][extname]';
|
|
86
|
+
},
|
|
87
|
+
},
|
|
88
|
+
},
|
|
89
|
+
},
|
|
90
|
+
|
|
91
|
+
// ========================================
|
|
92
|
+
// DEV SERVER
|
|
93
|
+
// ========================================
|
|
94
|
+
server: {
|
|
95
|
+
port: 8080,
|
|
96
|
+
open: true, // Auto-open browser on start
|
|
97
|
+
},
|
|
98
|
+
|
|
99
|
+
// Preview server (for testing production builds locally)
|
|
100
|
+
preview: {
|
|
101
|
+
port: 8080,
|
|
102
|
+
},
|
|
103
|
+
|
|
104
|
+
// Polyfill process.env for libraries that expect Node.js environment
|
|
105
|
+
define: {
|
|
106
|
+
'process.env': {},
|
|
107
|
+
},
|
|
108
|
+
};
|
|
109
|
+
});
|