create-wordpress-theme-ts 1.0.0 → 1.0.2
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/bin/index.js +60 -8
- package/package.json +1 -1
- package/template/.env +0 -0
- package/template/eslint.config.js +71 -0
- package/template/package-lock.json +6058 -6323
- package/template/package.json +45 -48
- package/template/public/assets/icons/favicon.ico +0 -0
- package/template/public/index.html +26 -0
- package/template/public/style.css +6 -43
- package/template/src/App.tsx +19 -19
- package/template/src/components/Layout.tsx +88 -88
- package/template/src/index.tsx +15 -15
- package/template/src/pages/About.tsx +65 -66
- package/template/src/pages/Home.tsx +135 -133
- package/template/src/pages/NotFound.tsx +55 -57
- package/template/src/styles/global.css +90 -90
- package/template/tsconfig.json +39 -20
- package/template/vite-env.d.ts +1 -0
- package/template/vite.config.ts +67 -109
- package/template/.eslintignore +0 -2
- package/template/.eslintrc.json +0 -34
- package/template/src/vite-env.d.ts +0 -7
package/template/vite.config.ts
CHANGED
|
@@ -1,109 +1,67 @@
|
|
|
1
|
-
import
|
|
2
|
-
import
|
|
3
|
-
import
|
|
4
|
-
import
|
|
5
|
-
import
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
}
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
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
|
-
});
|
|
1
|
+
import react from '@vitejs/plugin-react';
|
|
2
|
+
import { defineConfig } from 'vite';
|
|
3
|
+
import { viteStaticCopy } from 'vite-plugin-static-copy';
|
|
4
|
+
import zipPack from 'vite-plugin-zip-pack';
|
|
5
|
+
import eslint from 'vite-plugin-eslint2';
|
|
6
|
+
import { resolve } from 'path';
|
|
7
|
+
|
|
8
|
+
// Generate timestamp suffix (YYYYMMDDHHmmss)
|
|
9
|
+
const timestamp = new Date().toISOString().replace(/[-:T]/g, '').slice(0, 14);
|
|
10
|
+
|
|
11
|
+
export default defineConfig(({ mode }) => ({
|
|
12
|
+
plugins: [
|
|
13
|
+
react(),
|
|
14
|
+
eslint({
|
|
15
|
+
emitWarning: true,
|
|
16
|
+
emitError: true,
|
|
17
|
+
}),
|
|
18
|
+
// Copy PHP files, style.css and favicon to dist root
|
|
19
|
+
viteStaticCopy({
|
|
20
|
+
targets: [
|
|
21
|
+
{ src: 'php/*', dest: '.' },
|
|
22
|
+
{ src: 'public/style.css', dest: '.' },
|
|
23
|
+
{ src: 'public/assets/icons/favicon.ico', dest: '.' },
|
|
24
|
+
],
|
|
25
|
+
}),
|
|
26
|
+
// Create ZIP file of the dist folder
|
|
27
|
+
zipPack({
|
|
28
|
+
outDir: 'dist',
|
|
29
|
+
outFileName: `wordpress-custom-theme-${timestamp}.zip`,
|
|
30
|
+
}),
|
|
31
|
+
],
|
|
32
|
+
root: '.', // Root directory where index.html is located
|
|
33
|
+
publicDir: false, // Disable Vite's default public dir copying since we're using viteStaticCopy
|
|
34
|
+
build: {
|
|
35
|
+
outDir: 'dist',
|
|
36
|
+
emptyOutDir: true,
|
|
37
|
+
sourcemap: mode === 'production', // Generate source maps for production
|
|
38
|
+
cssCodeSplit: false, // Extract all CSS into a single file
|
|
39
|
+
rollupOptions: {
|
|
40
|
+
input: resolve(__dirname, 'index.html'),
|
|
41
|
+
output: {
|
|
42
|
+
format: 'iife', // Output as IIFE format for browser compatibility (no ES module exports)
|
|
43
|
+
entryFileNames: 'bundle.js', // Name the main bundle 'bundle.js' since required by WordPress themes
|
|
44
|
+
chunkFileNames: '[name].js', // For any code-split chunks (if any)
|
|
45
|
+
// For assets like images, fonts
|
|
46
|
+
assetFileNames: (assetInfo) => {
|
|
47
|
+
// Output bundled CSS as bundle.css (separate from WordPress theme's style.css)
|
|
48
|
+
const name = assetInfo.names?.[0] || '';
|
|
49
|
+
if (name.endsWith('.css')) {
|
|
50
|
+
return 'bundle.css';
|
|
51
|
+
}
|
|
52
|
+
return 'assets/[name][extname]';
|
|
53
|
+
},
|
|
54
|
+
},
|
|
55
|
+
},
|
|
56
|
+
minify: mode === 'production' ? 'terser' : false, // Minify in production
|
|
57
|
+
},
|
|
58
|
+
// Development server configuration
|
|
59
|
+
server: {
|
|
60
|
+
port: 8080,
|
|
61
|
+
open: true,
|
|
62
|
+
},
|
|
63
|
+
// Module resolution configuration
|
|
64
|
+
resolve: {
|
|
65
|
+
extensions: ['.tsx', '.ts', '.js'],
|
|
66
|
+
},
|
|
67
|
+
}));
|
package/template/.eslintignore
DELETED
package/template/.eslintrc.json
DELETED
|
@@ -1,34 +0,0 @@
|
|
|
1
|
-
{
|
|
2
|
-
"env": {
|
|
3
|
-
"browser": true,
|
|
4
|
-
"es2021": true,
|
|
5
|
-
"node": true
|
|
6
|
-
},
|
|
7
|
-
"extends": [
|
|
8
|
-
"eslint:recommended",
|
|
9
|
-
"plugin:react/recommended",
|
|
10
|
-
"plugin:react-hooks/recommended",
|
|
11
|
-
"plugin:@typescript-eslint/recommended",
|
|
12
|
-
"plugin:prettier/recommended"
|
|
13
|
-
],
|
|
14
|
-
"parser": "@typescript-eslint/parser",
|
|
15
|
-
"parserOptions": {
|
|
16
|
-
"ecmaFeatures": {
|
|
17
|
-
"jsx": true
|
|
18
|
-
},
|
|
19
|
-
"ecmaVersion": "latest",
|
|
20
|
-
"sourceType": "module"
|
|
21
|
-
},
|
|
22
|
-
"plugins": ["react", "@typescript-eslint", "prettier"],
|
|
23
|
-
"rules": {
|
|
24
|
-
"react/react-in-jsx-scope": "off",
|
|
25
|
-
"react/no-unescaped-entities": "off",
|
|
26
|
-
"prettier/prettier": "error",
|
|
27
|
-
"@typescript-eslint/no-unused-vars": ["warn", { "argsIgnorePattern": "^_" }]
|
|
28
|
-
},
|
|
29
|
-
"settings": {
|
|
30
|
-
"react": {
|
|
31
|
-
"version": "detect"
|
|
32
|
-
}
|
|
33
|
-
}
|
|
34
|
-
}
|
|
@@ -1,7 +0,0 @@
|
|
|
1
|
-
/// <reference types="vite/client" />
|
|
2
|
-
|
|
3
|
-
// Type declaration for vite-plugin-eslint (no @types package available)
|
|
4
|
-
declare module 'vite-plugin-eslint' {
|
|
5
|
-
import { Plugin } from 'vite';
|
|
6
|
-
export default function eslint(options?: Record<string, unknown>): Plugin;
|
|
7
|
-
}
|