refactor(assets): align dist filenames with webpack manifest#488
refactor(assets): align dist filenames with webpack manifest#488firestar300 wants to merge 4 commits intomasterfrom
Conversation
- Use stable output names in production (app.js, [name].css) and same MiniCssExtract + WebpackManifestPlugin in all modes. - Register theme JS/CSS from assets.json only; remove is_minified() and SCRIPT_DEBUG-based branching. - Fix get_asset_data() static cache to key by the requested filename. - Update PHPDoc and inline comments to match the new flow.
Add empty-file check, dist/login.css fallback, and pass through filter default to avoid invalid dist/ URL when get_min_file returns empty.
There was a problem hiding this comment.
Cursor Bugbot has reviewed your changes and found 2 potential issues.
❌ Bugbot Autofix is OFF. To automatically fix reported issues with cloud agents, enable autofix in the Cursor dashboard.
Reviewed by Cursor Bugbot for commit d2775dc. Configure here.
| $theme = wp_get_theme(); | ||
|
|
||
| // Js | ||
| $file = $this->is_minified() ? $this->get_min_file( 'js' ) : 'app.js'; |
There was a problem hiding this comment.
JS registration lacks empty-file guard unlike CSS paths
Medium Severity
get_min_file('js') returns an empty string when assets.json is absent or lacks the app.js key. In that case register_script is called with path 'dist/', registering a broken script URL pointing to a directory. The CSS equivalents (stylesheet_uri and login_stylesheet_uri) both have proper fallback chains (check for empty, try a hardcoded dist/app.css, then fall back to the original URI), but the JS registration has no guard or fallback at all. The old ternary guaranteed a non-empty 'app.js' fallback in dev mode; removing it without adding an equivalent guard leaves the JS path unprotected.
Additional Locations (1)
Reviewed by Cursor Bugbot for commit d2775dc. Configure here.
| */ | ||
| public function admin_editor_script(): void { | ||
| $file = $this->assets->is_minified() ? $this->assets->get_min_file( 'editor.js' ) : 'editor.js'; | ||
| $file = $this->assets->get_min_file( 'editor.js' ); |
There was a problem hiding this comment.
Editor script guard bypassed when file is empty
Medium Severity
When get_min_file('editor.js') returns an empty string, $filepath becomes 'dist/'. The guard on line 83 uses file_exists(), which returns true for directories, so the check is bypassed and a broken script is registered at 'dist/'. The sibling style() method correctly uses is_file() for its guard, which returns false for directories. Previously the hardcoded 'editor.js' fallback in dev mode prevented $file from ever being empty; removing that fallback makes this guard ineffective.
Reviewed by Cursor Bugbot for commit d2775dc. Configure here.
|
TODO : |


Note
Medium Risk
Asset build output naming and WordPress theme asset resolution logic are changed to rely on
assets.json, which could break script/style loading if the manifest or built files are missing or mismatched.Overview
Switches webpack to stable production filenames (
[name].js,[name].css) and always emitsassets.json/extracts CSS viaWebpackManifestPlugin+MiniCssExtractPluginin all modes (bundle analysis remains production-only).Refactors PHP asset registration to always resolve JS/CSS/editor/login assets via
dist/assets.json(removingSCRIPT_DEBUG/is_minified()branching), adds file-existence fallbacks for theme and login stylesheets, and fixesget_asset_data()’s static cache to key by the requested filename.Reviewed by Cursor Bugbot for commit d2775dc. Bugbot is set up for automated code reviews on this repo. Configure here.