进行了一些小修复

This commit is contained in:
2026-08-26 13:30:02 +08:00
parent 065a5bc99c
commit ed1a47cf4e
7 changed files with 71 additions and 6 deletions
@@ -431,3 +431,36 @@ test('legacy frontend toast APIs and selectors are fully removed', () => {
const offenders = scanned.filter((file) => legacy.test(fs.readFileSync(file, 'utf8')));
assert.deepEqual(offenders.map((file) => path.relative(root, file)), []);
});
test('public CSS bundles have parser-minified production variants', () => {
const builder = read('tools/build-public-assets.mjs');
assert.match(builder, /require\('esbuild'\)/);
assert.match(builder, /loader: 'css'/);
assert.match(builder, /minify: true/);
for (const basename of ['public', 'homepage']) {
const readablePath = path.join(root, 'assets', 'css', 'build', `${basename}.css`);
const minifiedPath = path.join(root, 'assets', 'css', 'build', `${basename}.min.css`);
assert.equal(fs.existsSync(readablePath), true, `${basename}.css must exist`);
assert.equal(fs.existsSync(minifiedPath), true, `${basename}.min.css must exist`);
assert.ok(
fs.statSync(minifiedPath).size < fs.statSync(readablePath).size * 0.9,
`${basename}.min.css should be at least 10% smaller`,
);
assert.doesNotMatch(fs.readFileSync(minifiedPath, 'utf8'), /\/\* source:/);
}
});
test('WordPress loads minified CSS with a readable-bundle fallback', () => {
const scripts = read('src/Core/ScriptsPart1b.php');
for (const basename of ['public', 'homepage']) {
assert.ok(
scripts.includes(`file_exists(get_template_directory() . '/assets/css/build/${basename}.min.css')`),
);
assert.match(scripts, new RegExp(`\\? '${basename}\\.min\\.css'`));
assert.match(scripts, new RegExp(`: '${basename}\\.css'`));
}
});