@ideasonpurpose/build-tools-wordpress 2.1.11 → 2.2.1
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/CHANGELOG.md +14 -0
- package/README.md +1 -1
- package/bin/format-php-prettier.js +10 -0
- package/config/webpack.config.js +35 -22
- package/lib/devserver-proxy.js +8 -1
- package/package.json +8 -6
package/CHANGELOG.md
CHANGED
|
@@ -4,6 +4,20 @@ All notable changes to this project will be documented in this file. Dates are d
|
|
|
4
4
|
|
|
5
5
|
Generated by [`auto-changelog`](https://github.com/CookPete/auto-changelog).
|
|
6
6
|
|
|
7
|
+
#### v2.2.0
|
|
8
|
+
|
|
9
|
+
> 7 September 2025
|
|
10
|
+
|
|
11
|
+
- bump deps
|
|
12
|
+
- Update websocket reload for v5, cleanup
|
|
13
|
+
- Testing some watch fixes
|
|
14
|
+
|
|
15
|
+
#### v2.1.11
|
|
16
|
+
|
|
17
|
+
> 3 September 2025
|
|
18
|
+
|
|
19
|
+
- bump deps
|
|
20
|
+
|
|
7
21
|
#### v2.1.10
|
|
8
22
|
|
|
9
23
|
> 3 September 2025
|
package/README.md
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
# @ideasonpurpose/build-tools-wordpress
|
|
2
2
|
|
|
3
|
-
#### Version 2.1
|
|
3
|
+
#### Version 2.2.1
|
|
4
4
|
|
|
5
5
|
[](https://www.npmjs.com/package/@ideasonpurpose/build-tools-wordpress)
|
|
6
6
|
[](https://github.com/ideasonpurpose/build-tools-wordpress#readme)
|
|
@@ -126,6 +126,16 @@ export function unTokenizeHTML(tokenizedHTML, phpCodeBlocks) {
|
|
|
126
126
|
return phpContent;
|
|
127
127
|
}
|
|
128
128
|
|
|
129
|
+
/**
|
|
130
|
+
* Formats a mixed HTML & PHP file with these steps:
|
|
131
|
+
* 1. Tokenize PHP Blocks as HTML-safe and attribute-safe strings
|
|
132
|
+
* 2. Format the result as HTML
|
|
133
|
+
* 3. Un-tokenize HTML back to PHP
|
|
134
|
+
* 4. Format again as PHP
|
|
135
|
+
* 5. Overwrite the file
|
|
136
|
+
*
|
|
137
|
+
* @param {string} filepath - The path to the file to format (must be a valid file path).
|
|
138
|
+
*/
|
|
129
139
|
async function formatHTMLThenPHP(filepath) {
|
|
130
140
|
try {
|
|
131
141
|
const startTime = process.hrtime.bigint();
|
package/config/webpack.config.js
CHANGED
|
@@ -16,7 +16,7 @@ import {
|
|
|
16
16
|
buildConfig,
|
|
17
17
|
DependencyManifestPlugin,
|
|
18
18
|
devserverProxy,
|
|
19
|
-
findLocalPort,
|
|
19
|
+
// findLocalPort,
|
|
20
20
|
WatchRunReporterPlugin,
|
|
21
21
|
} from "../index.js";
|
|
22
22
|
|
|
@@ -107,6 +107,19 @@ export default async (env) => {
|
|
|
107
107
|
|
|
108
108
|
const devtool = config.devtool || false;
|
|
109
109
|
|
|
110
|
+
// Debug: Log the watchFiles paths
|
|
111
|
+
const watchPath =
|
|
112
|
+
path.resolve(config.src, "..") + "/**/*.{php,html,svg,json}";
|
|
113
|
+
console.log(chalk.cyan("🔍 Watching files:"), watchPath);
|
|
114
|
+
console.log(
|
|
115
|
+
chalk.cyan("📁 Theme directory:"),
|
|
116
|
+
path.resolve(config.src, ".."),
|
|
117
|
+
);
|
|
118
|
+
|
|
119
|
+
// // Temporarily disable polling to test native file watching
|
|
120
|
+
// const usePollingDebug = false; // Set to false to test without polling
|
|
121
|
+
// const pollIntervalDebug = 400;
|
|
122
|
+
|
|
110
123
|
return {
|
|
111
124
|
stats,
|
|
112
125
|
module: {
|
|
@@ -248,7 +261,6 @@ export default async (env) => {
|
|
|
248
261
|
host: "0.0.0.0",
|
|
249
262
|
allowedHosts: "all",
|
|
250
263
|
port: "auto",
|
|
251
|
-
// hot: true, // TODO: What does 'only' do? https://webpack.js.org/configuration/dev-server/#devserverhot
|
|
252
264
|
hot: true, // Enable hot module replacement with fallback to full reload
|
|
253
265
|
client: {
|
|
254
266
|
logging: "info",
|
|
@@ -278,8 +290,10 @@ export default async (env) => {
|
|
|
278
290
|
if (/.+(hot-update)\.(js|json|js\.map)$/.test(filePath)) {
|
|
279
291
|
return false;
|
|
280
292
|
}
|
|
281
|
-
|
|
282
|
-
|
|
293
|
+
|
|
294
|
+
// // SHORT_CIRCUIT FOR TESTING
|
|
295
|
+
// console.log("DEBUG writeToDisk:", { filePath });
|
|
296
|
+
// return true;
|
|
283
297
|
|
|
284
298
|
if (/.+\.(svg|json|php|jpg|png)$/.test(filePath)) {
|
|
285
299
|
const fileStat = statSync(filePath, { throwIfNoEntry: false });
|
|
@@ -309,6 +323,11 @@ export default async (env) => {
|
|
|
309
323
|
// console.log("DEBUG writeToDisk:", { cached: relPath });
|
|
310
324
|
}
|
|
311
325
|
}
|
|
326
|
+
|
|
327
|
+
// SHORT_CIRCUIT FOR TESTING
|
|
328
|
+
return true;
|
|
329
|
+
|
|
330
|
+
console.log("DEBUG writeToDisk:", { filePath });
|
|
312
331
|
return false;
|
|
313
332
|
},
|
|
314
333
|
// stats,
|
|
@@ -331,13 +350,6 @@ export default async (env) => {
|
|
|
331
350
|
},
|
|
332
351
|
|
|
333
352
|
setupMiddlewares: (middlewares, devServer) => {
|
|
334
|
-
// devServer.compiler.options.devServer.port = devServer.options.port;
|
|
335
|
-
// devServer.compiler._devServer = devServer;
|
|
336
|
-
// if (!devServer) {
|
|
337
|
-
// throw new Error("webpack-dev-server is not defined");
|
|
338
|
-
// }
|
|
339
|
-
|
|
340
|
-
// devServer.internalIP('v4').then(ip => console.log('!!!!!!', ip));
|
|
341
353
|
|
|
342
354
|
/**
|
|
343
355
|
* The `/inform` route is an annoying bit of code. Here's why:
|
|
@@ -352,9 +364,12 @@ export default async (env) => {
|
|
|
352
364
|
|
|
353
365
|
/**
|
|
354
366
|
* The "/webpack/reload" endpoint will trigger a full devServer refresh
|
|
355
|
-
* Originally from our Browsersync implementation:
|
|
356
367
|
*
|
|
357
|
-
* https://github.com/
|
|
368
|
+
* @link https://github.com/webpack/webpack-dev-server/blob/master/migration-v5.md#-breaking-changes
|
|
369
|
+
* @link https://github.com/webpack/webpack-dev-server/issues/3121#issuecomment-3264080704
|
|
370
|
+
*
|
|
371
|
+
* Originally from our Browsersync implementation:
|
|
372
|
+
* @link https://github.com/ideasonpurpose/wp-theme-init/blob/ad8039c9757ffc3a0a0ed0adcc616a013fdc8604/src/ThemeInit.php#L202
|
|
358
373
|
*/
|
|
359
374
|
devServer.app.get("/webpack/reload", (req, res) => {
|
|
360
375
|
console.log(
|
|
@@ -363,8 +378,9 @@ export default async (env) => {
|
|
|
363
378
|
|
|
364
379
|
devServer.sendMessage(
|
|
365
380
|
devServer.webSocketServer.clients,
|
|
366
|
-
"
|
|
381
|
+
"static-changed",
|
|
367
382
|
);
|
|
383
|
+
|
|
368
384
|
res.json({ status: "Reloading!" });
|
|
369
385
|
});
|
|
370
386
|
|
|
@@ -373,7 +389,8 @@ export default async (env) => {
|
|
|
373
389
|
|
|
374
390
|
watchFiles: {
|
|
375
391
|
paths: [
|
|
376
|
-
|
|
392
|
+
// Watch all PHP, HTML, SVG, and JSON files in the theme directory
|
|
393
|
+
path.resolve(config.src, "..") + "/**/*.{php,html,svg,json}",
|
|
377
394
|
],
|
|
378
395
|
options: {
|
|
379
396
|
ignored: [
|
|
@@ -382,14 +399,10 @@ export default async (env) => {
|
|
|
382
399
|
"**/node_modules/**",
|
|
383
400
|
"**/dist/**",
|
|
384
401
|
],
|
|
385
|
-
ignoreInitial:
|
|
402
|
+
ignoreInitial: false, // Allow initial file discovery
|
|
386
403
|
ignorePermissionErrors: true,
|
|
387
|
-
|
|
388
|
-
|
|
389
|
-
* @link https://github.com/docker/for-win/issues/56#issuecomment-576749639
|
|
390
|
-
*/
|
|
391
|
-
usePolling,
|
|
392
|
-
interval: pollInterval,
|
|
404
|
+
usePolling: false,
|
|
405
|
+
// interval: pollIntervalDebug,
|
|
393
406
|
},
|
|
394
407
|
},
|
|
395
408
|
|
package/lib/devserver-proxy.js
CHANGED
|
@@ -61,7 +61,13 @@ export async function devserverProxy(config) {
|
|
|
61
61
|
|
|
62
62
|
const proxy = [
|
|
63
63
|
{
|
|
64
|
-
context: [
|
|
64
|
+
context: [
|
|
65
|
+
"**",
|
|
66
|
+
"!/ws",
|
|
67
|
+
"!/sockjs-node",
|
|
68
|
+
"!/__webpack_dev_server__",
|
|
69
|
+
"!/webpack-dev-server",
|
|
70
|
+
],
|
|
65
71
|
target: target.origin,
|
|
66
72
|
secure: false,
|
|
67
73
|
autoRewrite: true,
|
|
@@ -69,6 +75,7 @@ export async function devserverProxy(config) {
|
|
|
69
75
|
changeOrigin: true, // needed for virtual hosted sites
|
|
70
76
|
cookieDomainRewrite: "", // was `${config.host}:8080` ??
|
|
71
77
|
headers: { "Accept-Encoding": "identity" },
|
|
78
|
+
ws: true,
|
|
72
79
|
|
|
73
80
|
onError: (err, req, res) => {
|
|
74
81
|
if (err.code === "ECONNRESET") {
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@ideasonpurpose/build-tools-wordpress",
|
|
3
|
-
"version": "2.1
|
|
3
|
+
"version": "2.2.1",
|
|
4
4
|
"description": "Build scripts and dependencies for IOP's WordPress development environments.",
|
|
5
5
|
"homepage": "https://github.com/ideasonpurpose/build-tools-wordpress#readme",
|
|
6
6
|
"bugs": {
|
|
@@ -35,6 +35,7 @@
|
|
|
35
35
|
"dependencies": {
|
|
36
36
|
"@ideasonpurpose/prettier-config": "^1.0.1",
|
|
37
37
|
"@ideasonpurpose/stylelint-config": "^1.1.1",
|
|
38
|
+
"@prettier/plugin-php": "^0.24.0",
|
|
38
39
|
"@rollup/plugin-commonjs": "^28.0.6",
|
|
39
40
|
"@rollup/plugin-json": "^6.1.0",
|
|
40
41
|
"@rollup/plugin-node-resolve": "^16.0.1",
|
|
@@ -45,8 +46,8 @@
|
|
|
45
46
|
"auto-changelog": "^2.5.0",
|
|
46
47
|
"autoprefixer": "^10.4.21",
|
|
47
48
|
"babel-loader": "^10.0.0",
|
|
48
|
-
"caniuse-lite": "^1.0.
|
|
49
|
-
"chalk": "^5.6.
|
|
49
|
+
"caniuse-lite": "^1.0.30001741",
|
|
50
|
+
"chalk": "^5.6.2",
|
|
50
51
|
"chalk-cli": "^6.0.0",
|
|
51
52
|
"classnames": "^2.5.1",
|
|
52
53
|
"cli-truncate": "^5.0.0",
|
|
@@ -57,7 +58,7 @@
|
|
|
57
58
|
"cssnano": "^7.1.1",
|
|
58
59
|
"dotenv": "^17.2.2",
|
|
59
60
|
"esbuild-loader": "^4.3.0",
|
|
60
|
-
"eslint": "^9.
|
|
61
|
+
"eslint": "^9.35.0",
|
|
61
62
|
"filesize": "^11.0.2",
|
|
62
63
|
"fs-extra": "^11.3.1",
|
|
63
64
|
"globby": "^14.1.0",
|
|
@@ -71,10 +72,11 @@
|
|
|
71
72
|
"postcss": "^8.5.6",
|
|
72
73
|
"postcss-loader": "^8.2.0",
|
|
73
74
|
"postcss-scss": "^4.0.9",
|
|
75
|
+
"prettier": "^3.6.2",
|
|
74
76
|
"pretty-hrtime": "^1.0.3",
|
|
75
77
|
"read-package-up": "^11.0.0",
|
|
76
78
|
"replacestream": "^4.0.3",
|
|
77
|
-
"sass-embedded": "^1.92.
|
|
79
|
+
"sass-embedded": "^1.92.1",
|
|
78
80
|
"sass-loader": "^16.0.5",
|
|
79
81
|
"semver": "^7.7.2",
|
|
80
82
|
"sharp": "^0.34.3",
|
|
@@ -86,7 +88,7 @@
|
|
|
86
88
|
"version-everything": "^0.11.4",
|
|
87
89
|
"webpack": "^5.101.3",
|
|
88
90
|
"webpack-bundle-analyzer": "^4.10.2",
|
|
89
|
-
"webpack-dev-middleware": "^7.4.
|
|
91
|
+
"webpack-dev-middleware": "^7.4.3",
|
|
90
92
|
"webpack-dev-server": "^5.2.2"
|
|
91
93
|
},
|
|
92
94
|
"peerDependencies": {
|