@ideasonpurpose/build-tools-wordpress 2.10.10 → 2.10.12
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/AGENTS.md +4 -3
- package/README.md +2 -2
- package/bin/format-wp-php.js +5 -7
- package/bin/refresh.js +182 -0
- package/bin/update-wp-image.js +4 -1
- package/biome.json +8 -1
- package/boilerplate/composer.json +4 -3
- package/boilerplate/package.json +3 -10
- package/config/ideasonpurpose.config.js +2 -1
- package/config/webpack.config.js +60 -94
- package/package.json +22 -18
- package/tooling/docker-compose.yml +1 -1
- /package/{example → boilerplate}/docker-compose.yml +0 -0
- /package/{example → boilerplate}/webpack.config.js +0 -0
package/AGENTS.md
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
<!--
|
|
2
2
|
Canonical AGENTS.md: https://gist.github.com/joemaller/d6154fbdb2e5f4670c0b9338d04189e9
|
|
3
|
-
Last Modified: 2026-07-
|
|
3
|
+
Last Modified: 2026-07-15
|
|
4
4
|
-->
|
|
5
5
|
|
|
6
6
|
# AI Coding Assistant Guidelines
|
|
@@ -35,7 +35,7 @@ Before implementing:
|
|
|
35
35
|
|
|
36
36
|
**Minimum code that solves the problem. Nothing speculative.**
|
|
37
37
|
|
|
38
|
-
- Use standard libraries and native platform features first. Suggest popular, well-maintained alternatives.
|
|
38
|
+
- Use standard libraries and native platform features first. Suggest popular, well-maintained alternatives.
|
|
39
39
|
- Prefer boring, obvious code over clever code.
|
|
40
40
|
- No features beyond what was asked.
|
|
41
41
|
- No abstractions for single-use code.
|
|
@@ -59,6 +59,7 @@ When editing existing code:
|
|
|
59
59
|
- Never run tests, linters or formatters unless asked.
|
|
60
60
|
- Never log secrets, API keys, tokens, or .env values. If that code exists, say something.
|
|
61
61
|
- Remove imports/variables/functions that _your_ changes orphaned.
|
|
62
|
+
- Always target case-sensitive filesystems. Use precise casing. Verify letter-case of filenames and paths.
|
|
62
63
|
|
|
63
64
|
Every changed line should trace directly to the user's request.
|
|
64
65
|
|
|
@@ -76,4 +77,4 @@ Every changed line should trace directly to the user's request.
|
|
|
76
77
|
|
|
77
78
|
Look for sibling `AGENTS-*.md` files for further instructions on specific concerns (e.g. stylesheets, WordPress development, static site development)
|
|
78
79
|
|
|
79
|
-
Whenever this file is modified, update the timestamp in the top comment.
|
|
80
|
+
Whenever this file is modified, update the timestamp in the top comment.
|
package/README.md
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
# @ideasonpurpose/build-tools-wordpress
|
|
2
2
|
|
|
3
|
-
#### Version 2.10.
|
|
3
|
+
#### Version 2.10.12
|
|
4
4
|
|
|
5
5
|
[](https://www.npmjs.com/package/@ideasonpurpose/build-tools-wordpress)
|
|
6
6
|
[](https://github.com/ideasonpurpose/build-tools-wordpress/actions/workflows/npm-publish.yml)
|
|
@@ -35,7 +35,7 @@ Typical host scripts (see [`boilerplate/package.json`](./boilerplate/package.jso
|
|
|
35
35
|
"zip": "iop-build-zip-archive"
|
|
36
36
|
},
|
|
37
37
|
"devDependencies": {
|
|
38
|
-
"@ideasonpurpose/build-tools-wordpress": "^2.10.
|
|
38
|
+
"@ideasonpurpose/build-tools-wordpress": "^2.10.12"
|
|
39
39
|
},
|
|
40
40
|
"prettier": "@ideasonpurpose/prettier-config",
|
|
41
41
|
"stylelint": {
|
package/bin/format-wp-php.js
CHANGED
|
@@ -7,7 +7,8 @@ import { realpathSync } from "node:fs";
|
|
|
7
7
|
import { resolve } from "node:path";
|
|
8
8
|
import { fileURLToPath } from "node:url";
|
|
9
9
|
|
|
10
|
-
const blockPatternPath =
|
|
10
|
+
const blockPatternPath =
|
|
11
|
+
/(?:^|\/)wp-content\/themes\/[^/]+\/patterns\/.*\.php$/;
|
|
11
12
|
|
|
12
13
|
/**
|
|
13
14
|
* @param {string} filepath
|
|
@@ -28,17 +29,13 @@ export async function main(args = process.argv.slice(2)) {
|
|
|
28
29
|
const filepath = args[fileFlagIndex + 1];
|
|
29
30
|
|
|
30
31
|
if (fileFlagIndex === -1 || !filepath) {
|
|
31
|
-
console.error(
|
|
32
|
-
"Usage: iop-format-wp-php --file <filepath> < input.php",
|
|
33
|
-
);
|
|
32
|
+
console.error("Usage: iop-format-wp-php --file <filepath> < input.php");
|
|
34
33
|
process.exitCode = 1;
|
|
35
34
|
return;
|
|
36
35
|
}
|
|
37
36
|
|
|
38
37
|
if (process.stdin.isTTY) {
|
|
39
|
-
console.error(
|
|
40
|
-
"Usage: iop-format-wp-php --file <filepath> < input.php",
|
|
41
|
-
);
|
|
38
|
+
console.error("Usage: iop-format-wp-php --file <filepath> < input.php");
|
|
42
39
|
process.exitCode = 1;
|
|
43
40
|
return;
|
|
44
41
|
}
|
|
@@ -52,6 +49,7 @@ export async function main(args = process.argv.slice(2)) {
|
|
|
52
49
|
stdio: ["pipe", "pipe", "inherit"],
|
|
53
50
|
});
|
|
54
51
|
process.stdout.write(formatted);
|
|
52
|
+
console.error(`Formatted with ${formatter}.`);
|
|
55
53
|
} catch (error) {
|
|
56
54
|
console.error(`Error running ${formatter}:`, error);
|
|
57
55
|
process.exitCode = 1;
|
package/bin/refresh.js
ADDED
|
@@ -0,0 +1,182 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
import { execSync } from "node:child_process";
|
|
3
|
+
import path from "node:path";
|
|
4
|
+
import { fileURLToPath } from "node:url";
|
|
5
|
+
import chalk from "chalk";
|
|
6
|
+
import fs from "fs-extra";
|
|
7
|
+
import { readPackageUp } from "read-package-up";
|
|
8
|
+
|
|
9
|
+
const __dirname = path.dirname(fileURLToPath(import.meta.url));
|
|
10
|
+
const boilerplateDir = path.resolve(__dirname, "../boilerplate");
|
|
11
|
+
|
|
12
|
+
const GITIGNORE_URL =
|
|
13
|
+
"https://gist.githubusercontent.com/joemaller/4f7518e0d04a82a3ca16/raw";
|
|
14
|
+
|
|
15
|
+
async function main() {
|
|
16
|
+
const args = process.argv.slice(2);
|
|
17
|
+
const force = args.includes("--force");
|
|
18
|
+
const dryRun = args.includes("--dry-run");
|
|
19
|
+
|
|
20
|
+
const pkgInfo = await readPackageUp({ cwd: process.cwd() });
|
|
21
|
+
if (!pkgInfo) {
|
|
22
|
+
console.error(chalk.red("No package.json found. Run from a project root."));
|
|
23
|
+
process.exit(1);
|
|
24
|
+
}
|
|
25
|
+
const projectRoot = path.dirname(pkgInfo.path);
|
|
26
|
+
const projectPkg = pkgInfo.packageJson;
|
|
27
|
+
|
|
28
|
+
if (!dryRun && !force) {
|
|
29
|
+
try {
|
|
30
|
+
const status = execSync("git status --porcelain", {
|
|
31
|
+
cwd: projectRoot,
|
|
32
|
+
encoding: "utf8",
|
|
33
|
+
}).trim();
|
|
34
|
+
if (status) {
|
|
35
|
+
console.log(
|
|
36
|
+
chalk.yellow(
|
|
37
|
+
"⚠️ Working tree is dirty. Use --force to proceed or --dry-run to preview.",
|
|
38
|
+
),
|
|
39
|
+
);
|
|
40
|
+
return;
|
|
41
|
+
}
|
|
42
|
+
} catch {
|
|
43
|
+
// no git, continue
|
|
44
|
+
}
|
|
45
|
+
}
|
|
46
|
+
|
|
47
|
+
console.log(chalk.blue("Refreshing project tooling..."));
|
|
48
|
+
|
|
49
|
+
// 1. Merge package.json
|
|
50
|
+
const templatePkg = await fs.readJson(
|
|
51
|
+
path.join(boilerplateDir, "package.json"),
|
|
52
|
+
);
|
|
53
|
+
// Drop scripts this package now manages so stale pre/post hooks don't block npm
|
|
54
|
+
const managedKeys = Object.keys(projectPkg.scripts || {}).filter((k) =>
|
|
55
|
+
["bootstrap", "project:refresh"].some((n) => k.includes(n)),
|
|
56
|
+
);
|
|
57
|
+
|
|
58
|
+
for (const k of managedKeys) {
|
|
59
|
+
delete projectPkg.scripts[k];
|
|
60
|
+
}
|
|
61
|
+
|
|
62
|
+
const keysToMerge = [
|
|
63
|
+
"scripts",
|
|
64
|
+
"devDependencies",
|
|
65
|
+
"version-everything",
|
|
66
|
+
"prettier",
|
|
67
|
+
"stylelint",
|
|
68
|
+
];
|
|
69
|
+
|
|
70
|
+
for (const key of keysToMerge) {
|
|
71
|
+
if (templatePkg[key]) {
|
|
72
|
+
projectPkg[key] = { ...(projectPkg[key] || {}), ...templatePkg[key] };
|
|
73
|
+
}
|
|
74
|
+
}
|
|
75
|
+
// preserve user values for name/desc/version
|
|
76
|
+
for (const k of ["name", "description", "version"]) {
|
|
77
|
+
if (projectPkg[k]) delete templatePkg[k];
|
|
78
|
+
}
|
|
79
|
+
|
|
80
|
+
Object.assign(projectPkg, templatePkg); // but safer selective already done
|
|
81
|
+
|
|
82
|
+
if (!dryRun) {
|
|
83
|
+
await fs.writeJson(path.join(projectRoot, "package.json"), projectPkg, {
|
|
84
|
+
spaces: 2,
|
|
85
|
+
});
|
|
86
|
+
console.log(chalk.green("✓ Updated package.json"));
|
|
87
|
+
} else {
|
|
88
|
+
console.log(chalk.gray("--dry-run: would update package.json"));
|
|
89
|
+
}
|
|
90
|
+
|
|
91
|
+
// 2. docker-compose.yml stub (includes this package's tooling/docker-compose.yml)
|
|
92
|
+
const composeSrc = path.join(boilerplateDir, "docker-compose.yml");
|
|
93
|
+
const composeDest = path.join(projectRoot, "docker-compose.yml");
|
|
94
|
+
if (!dryRun) {
|
|
95
|
+
await fs.copy(composeSrc, composeDest, { overwrite: true });
|
|
96
|
+
console.log(chalk.green("✓ Updated docker-compose.yml"));
|
|
97
|
+
}
|
|
98
|
+
|
|
99
|
+
// 3. webpack.config.js stub
|
|
100
|
+
const webpackSrc = path.join(boilerplateDir, "webpack.config.js");
|
|
101
|
+
const webpackDest = path.join(projectRoot, "webpack.config.js");
|
|
102
|
+
|
|
103
|
+
if (!dryRun) {
|
|
104
|
+
await fs.copy(webpackSrc, webpackDest, { overwrite: true });
|
|
105
|
+
console.log(chalk.green("✓ Updated webpack.config.js"));
|
|
106
|
+
}
|
|
107
|
+
|
|
108
|
+
// 4. biome.json
|
|
109
|
+
const biomeSrc = path.resolve(__dirname, "../biome.json");
|
|
110
|
+
|
|
111
|
+
const biomeDest = path.join(projectRoot, "biome.json");
|
|
112
|
+
if (!dryRun) {
|
|
113
|
+
await fs.copy(biomeSrc, biomeDest, { overwrite: true });
|
|
114
|
+
console.log(chalk.green("✓ Updated biome.json"));
|
|
115
|
+
}
|
|
116
|
+
|
|
117
|
+
// 5. svgo.config.mjs
|
|
118
|
+
const svgoSrc = path.resolve(__dirname, "../config/svgo.config.mjs");
|
|
119
|
+
|
|
120
|
+
const svgoDest = path.join(projectRoot, "svgo.config.mjs");
|
|
121
|
+
if (!dryRun) {
|
|
122
|
+
await fs.copy(svgoSrc, svgoDest, { overwrite: true });
|
|
123
|
+
console.log(chalk.green("✓ Updated svgo.config.mjs"));
|
|
124
|
+
}
|
|
125
|
+
|
|
126
|
+
// 6. .env.sample
|
|
127
|
+
const envSrc = path.join(boilerplateDir, ".env.sample");
|
|
128
|
+
const envDest = path.join(projectRoot, ".env.sample");
|
|
129
|
+
if (!dryRun) {
|
|
130
|
+
await fs.copy(envSrc, envDest, { overwrite: true });
|
|
131
|
+
console.log(chalk.green("✓ Updated .env.sample"));
|
|
132
|
+
}
|
|
133
|
+
|
|
134
|
+
// 7. .gitignore from gist
|
|
135
|
+
try {
|
|
136
|
+
const res = await fetch(GITIGNORE_URL);
|
|
137
|
+
const gitignore = await res.text();
|
|
138
|
+
if (!dryRun) {
|
|
139
|
+
await fs.writeFile(path.join(projectRoot, ".gitignore"), gitignore);
|
|
140
|
+
console.log(chalk.green("✓ Updated .gitignore from gist"));
|
|
141
|
+
}
|
|
142
|
+
} catch (e) {
|
|
143
|
+
console.warn(chalk.yellow("Could not fetch .gitignore: " + e.message));
|
|
144
|
+
}
|
|
145
|
+
|
|
146
|
+
// 8. create dirs
|
|
147
|
+
const dirs = ["_db", "wp-content/plugins", "wp-content/uploads"];
|
|
148
|
+
|
|
149
|
+
for (const d of dirs) {
|
|
150
|
+
const full = path.join(projectRoot, d);
|
|
151
|
+
if (!(await fs.pathExists(full))) {
|
|
152
|
+
if (!dryRun) await fs.mkdirp(full);
|
|
153
|
+
}
|
|
154
|
+
}
|
|
155
|
+
|
|
156
|
+
// 9. composer.json if missing
|
|
157
|
+
const composerSrc = path.join(boilerplateDir, "composer.json");
|
|
158
|
+
const composerDest = path.join(projectRoot, "composer.json");
|
|
159
|
+
if (!(await fs.pathExists(composerDest))) {
|
|
160
|
+
if (!dryRun) {
|
|
161
|
+
await fs.copy(composerSrc, composerDest);
|
|
162
|
+
console.log(chalk.green("✓ Created composer.json"));
|
|
163
|
+
}
|
|
164
|
+
}
|
|
165
|
+
|
|
166
|
+
// 10. Print next steps
|
|
167
|
+
if (!dryRun) {
|
|
168
|
+
console.log("");
|
|
169
|
+
console.log(chalk.cyan("Run these to finish setup:"));
|
|
170
|
+
console.log(chalk.cyan(" npm install"));
|
|
171
|
+
console.log(chalk.cyan(" docker compose pull"));
|
|
172
|
+
console.log(chalk.cyan(" npm run composer:update"));
|
|
173
|
+
}
|
|
174
|
+
|
|
175
|
+
if (dryRun) console.log(chalk.gray("Dry run complete."));
|
|
176
|
+
}
|
|
177
|
+
|
|
178
|
+
main().catch((e) => {
|
|
179
|
+
console.error(chalk.red(e.message));
|
|
180
|
+
|
|
181
|
+
process.exit(1);
|
|
182
|
+
});
|
package/bin/update-wp-image.js
CHANGED
|
@@ -38,4 +38,7 @@ if (!IMAGE_RE.test(yaml)) {
|
|
|
38
38
|
|
|
39
39
|
const image = `ideasonpurpose/wordpress:${wordpress}`;
|
|
40
40
|
await writeFile(composePath, yaml.replace(IMAGE_RE, `$1${image}`));
|
|
41
|
-
console.log(
|
|
41
|
+
console.log(
|
|
42
|
+
"✅",
|
|
43
|
+
chalk.green(`docker-compose WordPress image updated to ${image}`),
|
|
44
|
+
);
|
package/biome.json
CHANGED
|
@@ -23,10 +23,17 @@
|
|
|
23
23
|
"useNodejsImportProtocol": {
|
|
24
24
|
"level": "error",
|
|
25
25
|
"fix": "safe"
|
|
26
|
-
}
|
|
26
|
+
},
|
|
27
|
+
"useTemplate": "off"
|
|
27
28
|
}
|
|
28
29
|
}
|
|
29
30
|
},
|
|
31
|
+
"html": {
|
|
32
|
+
"formatter": {
|
|
33
|
+
"enabled": true
|
|
34
|
+
},
|
|
35
|
+
"experimentalFullSupportEnabled": true
|
|
36
|
+
},
|
|
30
37
|
"javascript": {
|
|
31
38
|
"formatter": {
|
|
32
39
|
"quoteStyle": "double"
|
|
@@ -26,10 +26,11 @@
|
|
|
26
26
|
},
|
|
27
27
|
"require": {
|
|
28
28
|
"ideasonpurpose/wp-admin-separators": "1.0.8",
|
|
29
|
-
"ideasonpurpose/wp-google-analytics": "^1.1.
|
|
29
|
+
"ideasonpurpose/wp-google-analytics": "^1.1.2",
|
|
30
30
|
"ideasonpurpose/wp-svg-lib": "^3.2.0",
|
|
31
|
+
"ideasonpurpose/wp-theme-addons": "^0.3.1",
|
|
31
32
|
"ideasonpurpose/wp-theme-i18n": "dev-main",
|
|
32
|
-
"ideasonpurpose/wp-theme-init": "^2.20.
|
|
33
|
+
"ideasonpurpose/wp-theme-init": "^2.20.14"
|
|
33
34
|
},
|
|
34
35
|
"repositories": [
|
|
35
36
|
{
|
|
@@ -38,6 +39,6 @@
|
|
|
38
39
|
}
|
|
39
40
|
],
|
|
40
41
|
"require-dev": {
|
|
41
|
-
"php-stubs/acf-pro-stubs": "^6.
|
|
42
|
+
"php-stubs/acf-pro-stubs": "^6.8.2"
|
|
42
43
|
}
|
|
43
44
|
}
|
package/boilerplate/package.json
CHANGED
|
@@ -12,11 +12,6 @@
|
|
|
12
12
|
"type": "module",
|
|
13
13
|
"main": "index.js",
|
|
14
14
|
"scripts": {
|
|
15
|
-
"_bootstrap:composer": "npm run composer:install",
|
|
16
|
-
"_bootstrap:npm": "npm ci",
|
|
17
|
-
"prebootstrap": "npm run permissions:repair",
|
|
18
|
-
"bootstrap": "npm run _bootstrap:npm && npm run _bootstrap:composer && npm run theme:activate",
|
|
19
|
-
"postbootstrap": "echo && echo ' 🚀' && echo ' ✨ All set!' && echo '🌏 Run this to get started:' && chalk bold yellow ' npm run start' && echo",
|
|
20
15
|
"prebuild": "npm run clean",
|
|
21
16
|
"build": "NODE_ENV=production webpack",
|
|
22
17
|
"postbuild": "npm run zip",
|
|
@@ -36,9 +31,7 @@
|
|
|
36
31
|
"mysqldump": "npm run db:dump",
|
|
37
32
|
"permissions:repair": "docker compose run --rm repair-permissions",
|
|
38
33
|
"phpmyadmin": "npm run db:admin",
|
|
39
|
-
"
|
|
40
|
-
"project:refresh": "docker compose run --rm refresh",
|
|
41
|
-
"postproject:refresh": "docker compose pull wordpress",
|
|
34
|
+
"project:refresh": "iop-project-refresh",
|
|
42
35
|
"pull": "npm run pull:db && npm run pull:plugins && npm run pull:uploads",
|
|
43
36
|
"prepull:db": "npm run db:dump",
|
|
44
37
|
"pull:db": "docker compose run --rm pull database",
|
|
@@ -63,7 +56,7 @@
|
|
|
63
56
|
"extends": "@ideasonpurpose/stylelint-config"
|
|
64
57
|
},
|
|
65
58
|
"devDependencies": {
|
|
66
|
-
"@ideasonpurpose/build-tools-wordpress": "^2.10.
|
|
59
|
+
"@ideasonpurpose/build-tools-wordpress": "^2.10.12"
|
|
67
60
|
},
|
|
68
61
|
"version-everything": {
|
|
69
62
|
"files": [
|
|
@@ -71,4 +64,4 @@
|
|
|
71
64
|
"wp-content/themes/iop-theme/style.css"
|
|
72
65
|
]
|
|
73
66
|
}
|
|
74
|
-
}
|
|
67
|
+
}
|
|
@@ -10,7 +10,8 @@
|
|
|
10
10
|
* theme name pulls instead from the docker image's package.json file, which will probably
|
|
11
11
|
* create a theme named 'iop-build-tools'.
|
|
12
12
|
*/
|
|
13
|
-
import { readFileSync } from "fs";
|
|
13
|
+
import { readFileSync } from "node:fs";
|
|
14
|
+
|
|
14
15
|
const packageJson = JSON.parse(readFileSync("./package.json"));
|
|
15
16
|
// import packageJson from "./package.json" with { type: "json" };
|
|
16
17
|
|
package/config/webpack.config.js
CHANGED
|
@@ -1,18 +1,17 @@
|
|
|
1
1
|
// @ts-check
|
|
2
2
|
|
|
3
|
-
import { posix as path } from "path";
|
|
4
|
-
|
|
5
|
-
import
|
|
6
|
-
import
|
|
3
|
+
import { posix as path } from "node:path";
|
|
4
|
+
// Experimenting with this
|
|
5
|
+
import DependencyExtractionWebpackPlugin from "@wordpress/dependency-extraction-webpack-plugin";
|
|
6
|
+
import autoprefixer from "autoprefixer";
|
|
7
7
|
import chalk from "chalk";
|
|
8
|
-
|
|
9
|
-
import MiniCssExtractPlugin from "mini-css-extract-plugin";
|
|
10
|
-
import { EsbuildPlugin } from "esbuild-loader";
|
|
11
|
-
|
|
12
8
|
import CopyPlugin from "copy-webpack-plugin";
|
|
13
|
-
import {
|
|
9
|
+
import { cosmiconfig, cosmiconfigSync } from "cosmiconfig";
|
|
10
|
+
import cssnano from "cssnano";
|
|
11
|
+
import { EsbuildPlugin } from "esbuild-loader";
|
|
14
12
|
import ImageMinimizerPlugin from "image-minimizer-webpack-plugin";
|
|
15
|
-
|
|
13
|
+
import MiniCssExtractPlugin from "mini-css-extract-plugin";
|
|
14
|
+
import { BundleAnalyzerPlugin } from "webpack-bundle-analyzer";
|
|
16
15
|
import {
|
|
17
16
|
AfterDoneReporterPlugin,
|
|
18
17
|
buildConfig,
|
|
@@ -22,12 +21,6 @@ import {
|
|
|
22
21
|
WatchRunReporterPlugin,
|
|
23
22
|
} from "../index.js";
|
|
24
23
|
|
|
25
|
-
import autoprefixer from "autoprefixer";
|
|
26
|
-
import cssnano from "cssnano";
|
|
27
|
-
|
|
28
|
-
// Experimenting with this
|
|
29
|
-
import DependencyExtractionWebpackPlugin from "@wordpress/dependency-extraction-webpack-plugin";
|
|
30
|
-
|
|
31
24
|
/**
|
|
32
25
|
* Force `mode: production` when running the analyzer
|
|
33
26
|
* TODO: webpack5 changed env in here, might need to change WEBPACK_BUNDLE_ANALYZER
|
|
@@ -371,59 +364,19 @@ export default async (env) => {
|
|
|
371
364
|
|
|
372
365
|
devMiddleware: {
|
|
373
366
|
index: false, // enable root proxying
|
|
367
|
+
/**
|
|
368
|
+
* @param {string} filePath
|
|
369
|
+
* @returns {boolean}
|
|
370
|
+
*/
|
|
371
|
+
/**
|
|
372
|
+
* A returned Promise is truthy → middleware writes every file.
|
|
373
|
+
* JS/CSS stay in memory (proxied). PHP/WordPress reads the rest from disk.
|
|
374
|
+
*/
|
|
374
375
|
writeToDisk: (filePath) => {
|
|
375
|
-
|
|
376
|
-
|
|
377
|
-
|
|
378
|
-
|
|
379
|
-
/**
|
|
380
|
-
* Note: If this is an async function, it will write everything to disk
|
|
381
|
-
*
|
|
382
|
-
* Never write hot-update files to disk.
|
|
383
|
-
*/
|
|
384
|
-
// vendors-node_modules_mini-css-extract-plugin_dist_hmr_hotModuleReplacement_js-node_modules_we-780fe4.js.map
|
|
385
|
-
if (/.+(hot-update)\.(js|json|js\.map)$/.test(filePath)) {
|
|
386
|
-
return false;
|
|
387
|
-
}
|
|
388
|
-
|
|
389
|
-
// // SHORT_CIRCUIT FOR TESTING
|
|
390
|
-
// console.log("DEBUG writeToDisk:", { filePath });
|
|
391
|
-
// return true;
|
|
392
|
-
|
|
393
|
-
if (/.+\.(svg|json|php|jpg|png)$/.test(filePath)) {
|
|
394
|
-
const fileStat = statSync(filePath, { throwIfNoEntry: false });
|
|
395
|
-
|
|
396
|
-
/**
|
|
397
|
-
* Always write SVG, PHP & JSON files
|
|
398
|
-
*/
|
|
399
|
-
if (/.+\.(svg|json|php)$/.test(filePath)) {
|
|
400
|
-
return true;
|
|
401
|
-
} else {
|
|
402
|
-
/**
|
|
403
|
-
* Write any images under 100k and anything not yet on disk
|
|
404
|
-
*/
|
|
405
|
-
if (!fileStat || fileStat.size < 100 * 1024) {
|
|
406
|
-
return true;
|
|
407
|
-
}
|
|
408
|
-
/**
|
|
409
|
-
* TODO: This might all be unnecessary. Webpack seems to be doing a good job with its native caching
|
|
410
|
-
*/
|
|
411
|
-
// const randOffset = Math.random() * 300000; // 0-5 minutes
|
|
412
|
-
// const expired = new Date() - fileStat.mtime > randOffset;
|
|
413
|
-
// const relPath = filePath.replace(config.dist, "dist");
|
|
414
|
-
// if (expired) {
|
|
415
|
-
// console.log("DEBUG writeToDisk:", { replacing: relPath });
|
|
416
|
-
// return true;
|
|
417
|
-
// }
|
|
418
|
-
// console.log("DEBUG writeToDisk:", { cached: relPath });
|
|
419
|
-
}
|
|
420
|
-
}
|
|
421
|
-
|
|
422
|
-
// SHORT_CIRCUIT FOR TESTING
|
|
423
|
-
// return true;
|
|
424
|
-
|
|
425
|
-
// console.log("DEBUG writeToDisk:", { filePath });
|
|
426
|
-
return false;
|
|
376
|
+
if (filePath.includes("hot-update")) return false;
|
|
377
|
+
return /\.(svg|json|php|jpe?g|png|gif|tif|webp|avif)$/i.test(
|
|
378
|
+
filePath,
|
|
379
|
+
);
|
|
427
380
|
},
|
|
428
381
|
// stats,
|
|
429
382
|
// stats: 'verbose',
|
|
@@ -436,13 +389,12 @@ export default async (env) => {
|
|
|
436
389
|
// },
|
|
437
390
|
|
|
438
391
|
/**
|
|
439
|
-
* @param {
|
|
392
|
+
* @param {InstanceType<typeof import('webpack-dev-server')>} devServer
|
|
440
393
|
*/
|
|
441
394
|
onListening: (devServer) => {
|
|
442
395
|
const port = devServer.server.address().port;
|
|
443
|
-
devServer.compiler.options.devServer.port =
|
|
444
|
-
|
|
445
|
-
devServer.compiler._devServer = devServer;
|
|
396
|
+
// devServer.compiler.options.devServer.port =
|
|
397
|
+
// devServer.server.address().port;
|
|
446
398
|
|
|
447
399
|
console.log(
|
|
448
400
|
chalk.cyan("●"),
|
|
@@ -452,8 +404,8 @@ export default async (env) => {
|
|
|
452
404
|
},
|
|
453
405
|
|
|
454
406
|
/**
|
|
455
|
-
* @param {
|
|
456
|
-
* @param {
|
|
407
|
+
* @param {import('webpack-dev-server').Middleware[]} middlewares
|
|
408
|
+
* @param {InstanceType<typeof import('webpack-dev-server')>} devServer
|
|
457
409
|
*/
|
|
458
410
|
setupMiddlewares: (middlewares, devServer) => {
|
|
459
411
|
/**
|
|
@@ -465,9 +417,16 @@ export default async (env) => {
|
|
|
465
417
|
* `/inform` requests with 404s, filling logs and cluttering
|
|
466
418
|
* terminals. So that's why this is here. I hate it.
|
|
467
419
|
*/
|
|
468
|
-
devServer.app.all(
|
|
469
|
-
|
|
470
|
-
|
|
420
|
+
devServer.app.all(
|
|
421
|
+
"/inform",
|
|
422
|
+
/**
|
|
423
|
+
* @param {import('express').Request} _req
|
|
424
|
+
* @param {import('express').Response} res
|
|
425
|
+
*/
|
|
426
|
+
(_req, res) => {
|
|
427
|
+
res.status(204).end();
|
|
428
|
+
},
|
|
429
|
+
);
|
|
471
430
|
|
|
472
431
|
/**
|
|
473
432
|
* The "/webpack/reload" endpoint will trigger a full devServer refresh
|
|
@@ -478,20 +437,27 @@ export default async (env) => {
|
|
|
478
437
|
* Originally from our Browsersync implementation:
|
|
479
438
|
* @link https://github.com/ideasonpurpose/wp-theme-init/blob/ad8039c9757ffc3a0a0ed0adcc616a013fdc8604/src/ThemeInit.php#L202
|
|
480
439
|
*/
|
|
481
|
-
devServer.app.get(
|
|
482
|
-
|
|
483
|
-
|
|
484
|
-
|
|
485
|
-
|
|
486
|
-
|
|
487
|
-
|
|
488
|
-
|
|
489
|
-
|
|
490
|
-
|
|
491
|
-
|
|
492
|
-
|
|
493
|
-
|
|
494
|
-
|
|
440
|
+
devServer.app.get(
|
|
441
|
+
"/webpack/reload",
|
|
442
|
+
/**
|
|
443
|
+
* @param {import('express').Request} _req
|
|
444
|
+
* @param {import('express').Response} res
|
|
445
|
+
*/
|
|
446
|
+
(_req, res) => {
|
|
447
|
+
console.log(
|
|
448
|
+
chalk.yellow("↻"),
|
|
449
|
+
chalk.yellow.bold("Reload:"),
|
|
450
|
+
"/webpack/reload",
|
|
451
|
+
);
|
|
452
|
+
|
|
453
|
+
devServer.sendMessage(
|
|
454
|
+
devServer.webSocketServer.clients,
|
|
455
|
+
"static-changed",
|
|
456
|
+
);
|
|
457
|
+
|
|
458
|
+
res.json({ status: "Reloading!" });
|
|
459
|
+
},
|
|
460
|
+
);
|
|
495
461
|
|
|
496
462
|
return middlewares;
|
|
497
463
|
},
|
|
@@ -556,7 +522,7 @@ export default async (env) => {
|
|
|
556
522
|
/**
|
|
557
523
|
* @link https://developer.wordpress.org/block-editor/reference-guides/packages/packages-dependency-extraction-webpack-plugin/
|
|
558
524
|
*/
|
|
559
|
-
new DependencyExtractionWebpackPlugin(),
|
|
525
|
+
new DependencyExtractionWebpackPlugin({}),
|
|
560
526
|
|
|
561
527
|
new DependencyManifestPlugin({
|
|
562
528
|
writeManifestFile: true,
|
|
@@ -564,11 +530,11 @@ export default async (env) => {
|
|
|
564
530
|
}),
|
|
565
531
|
|
|
566
532
|
new WatchRunReporterPlugin({
|
|
567
|
-
echo: env
|
|
533
|
+
echo: env?.WEBPACK_SERVE,
|
|
568
534
|
}),
|
|
569
535
|
|
|
570
536
|
new AfterDoneReporterPlugin({
|
|
571
|
-
echo: env
|
|
537
|
+
echo: env?.WEBPACK_SERVE,
|
|
572
538
|
}),
|
|
573
539
|
new BundleAnalyzerPlugin({
|
|
574
540
|
analyzerMode: isProduction ? "static" : "disabled",
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@ideasonpurpose/build-tools-wordpress",
|
|
3
|
-
"version": "2.10.
|
|
3
|
+
"version": "2.10.12",
|
|
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": {
|
|
@@ -44,33 +44,33 @@
|
|
|
44
44
|
"@rollup/plugin-json": "^6.1.0",
|
|
45
45
|
"@rollup/plugin-node-resolve": "^16.0.3",
|
|
46
46
|
"@svgr/webpack": "^8.1.0",
|
|
47
|
-
"@wordpress/dependency-extraction-webpack-plugin": "^6.
|
|
47
|
+
"@wordpress/dependency-extraction-webpack-plugin": "^6.54.0",
|
|
48
48
|
"ansi-html": "^0.0.9",
|
|
49
49
|
"archiver": "^8.0.0",
|
|
50
50
|
"autoprefixer": "^10.5.4",
|
|
51
51
|
"babel-loader": "^10.1.1",
|
|
52
|
-
"caniuse-lite": "^1.0.
|
|
52
|
+
"caniuse-lite": "^1.0.30001810",
|
|
53
53
|
"chalk": "^6.0.0",
|
|
54
54
|
"chalk-cli": "^6.0.0",
|
|
55
55
|
"classnames": "^2.5.1",
|
|
56
56
|
"cli-truncate": "^6.1.1",
|
|
57
57
|
"copy-webpack-plugin": "^14.0.0",
|
|
58
|
-
"cosmiconfig": "^10.0.
|
|
59
|
-
"css-loader": "^7.1.
|
|
60
|
-
"cssnano": "^8.0.
|
|
58
|
+
"cosmiconfig": "^10.0.1",
|
|
59
|
+
"css-loader": "^7.1.5",
|
|
60
|
+
"cssnano": "^8.0.10",
|
|
61
61
|
"dotenv": "^17.4.2",
|
|
62
62
|
"esbuild-loader": "^4.5.0",
|
|
63
|
-
"eslint": "^10.
|
|
63
|
+
"eslint": "^10.9.1",
|
|
64
64
|
"filesize": "^11.0.22",
|
|
65
65
|
"fs-extra": "^11.4.0",
|
|
66
|
-
"globby": "^16.2.
|
|
66
|
+
"globby": "^16.2.4",
|
|
67
67
|
"html-webpack-plugin": "^5.6.8",
|
|
68
|
-
"humanize-duration": "^3.34.
|
|
68
|
+
"humanize-duration": "^3.34.1",
|
|
69
69
|
"image-minimizer-webpack-plugin": "^5.0.0",
|
|
70
70
|
"is-text-path": "^3.0.0",
|
|
71
71
|
"lodash": "^4.18.1",
|
|
72
72
|
"mini-css-extract-plugin": "^2.10.2",
|
|
73
|
-
"open": "^11.0.
|
|
73
|
+
"open": "^11.0.2",
|
|
74
74
|
"ora": "^9.4.1",
|
|
75
75
|
"postcss": "^8.5.26",
|
|
76
76
|
"postcss-loader": "^8.2.1",
|
|
@@ -80,19 +80,19 @@
|
|
|
80
80
|
"read-package-up": "^12.0.0",
|
|
81
81
|
"replacestream": "^4.0.3",
|
|
82
82
|
"rimraf": "^6.1.3",
|
|
83
|
-
"sass-embedded": "^1.
|
|
84
|
-
"sass-loader": "^17.0.
|
|
83
|
+
"sass-embedded": "^1.103.1",
|
|
84
|
+
"sass-loader": "^17.0.1",
|
|
85
85
|
"semver": "^7.8.5",
|
|
86
|
-
"sharp": "^0.35.
|
|
86
|
+
"sharp": "^0.35.4",
|
|
87
87
|
"sort-package-json": "^4.0.0",
|
|
88
88
|
"string-length": "^7.0.1",
|
|
89
89
|
"style-loader": "^4.0.0",
|
|
90
|
-
"svgo": "^4.0
|
|
90
|
+
"svgo": "^4.1.0",
|
|
91
91
|
"svgo-loader": "^5.0.0",
|
|
92
92
|
"version-everything": "^0.12.2",
|
|
93
|
-
"webpack": "^5.
|
|
94
|
-
"webpack-bundle-analyzer": "^5.3.
|
|
95
|
-
"webpack-cli": "^7.2.
|
|
93
|
+
"webpack": "^5.110.3",
|
|
94
|
+
"webpack-bundle-analyzer": "^5.3.2",
|
|
95
|
+
"webpack-cli": "^7.2.3",
|
|
96
96
|
"webpack-dev-server": "^6.0.0",
|
|
97
97
|
"webpack-manifest-plugin": "^6.0.1"
|
|
98
98
|
},
|
|
@@ -105,7 +105,11 @@
|
|
|
105
105
|
},
|
|
106
106
|
"version-everything": {
|
|
107
107
|
"files": [
|
|
108
|
-
"README.md"
|
|
108
|
+
"README.md",
|
|
109
|
+
"boilerplate/package.json"
|
|
110
|
+
],
|
|
111
|
+
"prefixes": [
|
|
112
|
+
"@ideasonpurpose/build-tools-wordpress\": \"\\^"
|
|
109
113
|
]
|
|
110
114
|
},
|
|
111
115
|
"allowScripts": {
|
|
File without changes
|
|
File without changes
|