-
Notifications
You must be signed in to change notification settings - Fork 9.3k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Error deploying static content when dev/js/minify_files is enabled in db but disabled at config.php #38117
Comments
Hi @JamesFX2. Thank you for your report.
Join Magento Community Engineering Slack and ask your questions in #github channel. |
Hi @engcom-November. Thank you for working on this issue.
|
Hello @JamesFX2, Thank you for the report and collaboration! Can you let us know the use case where you want the Thank you. |
I would have to refresh my memory but I believe the issue is caused by scopes more than the specifics of the config.php and the way that scope is determined using a relative rather than absolute path. In retrospect, the only issue may be how scope is determined for the require files. |
Hello @JamesFX2, We would need more information on that, can you please elaborate on the same. |
Hello @JamesFX2, Could you please let us know the use case and when are you getting this issue. |
Hello @JamesFX2, As there is no activity on this issue for a long time, we believe the issue has been resolved, hence closing this issue. Thank you. |
Preconditions and environment
Basically, in an edge case, neither requirejs-config.min.js nor requirejs-min-resolver.min.js are generated.
Steps to reproduce
This is caused by our config.php settings but the actual bug is the inconsistent behaviour this causes.
Whereas the core_config_data setting is 'dev/js/minify_files' 1 at default scope.
Expected result
Deployment successful.
Actual result
Error occurs preventing deployment
Additional information
During a setup:static-content:deploy, the requirejs-config.js and requirejs-min-resolver.js files are generated here
https://github.com/magento/magento2/blob/2.4-develop/app/code/Magento/Deploy/Service/DeployRequireJsConfig.php#L113-L115
At this stage, Magento tries to determine whether or not the files should be minified or not.
The function to determine whether not a filename should be minified or not is in \Magento\Framework\View\Asset\Minification, the function is called addMinifiedSign. During the process that GENERATES the files, the argument that is passed is just the file names, requirejs-min-resolver.js and requirejs-config.js - not the relative path.
See (1) https://github.com/magento/magento2/blob/2.4-develop/lib/internal/Magento/Framework/RequireJs/Config.php#L180C21-L183 and (2) https://github.com/magento/magento2/blob/2.4-develop/lib/internal/Magento/Framework/RequireJs/Config.php#L238-L244
So eventually requirejs-config.js is passed to the isEnabledForArea function and since the filename is passed, not the relative path, $area is !== 'adminhtml' and when $this->isEnabled('js') is called, it returns false, relevant code below.
https://github.com/magento/magento2/blob/2.4-develop/lib/internal/Magento/Framework/View/Asset/Minification.php#L194-L215
When the generated files are later read, the relative path of "adminhtml/Magento/backend/en_US/requirejs-config.js" is later passed into the addMinifiedSign to try to determine the location of the file - because the path is now relative and has adminhtml as the area, it presumes that the path should be minified. This is the secondary source of the deployment error.
My recommendation is to modify \Magento\Framework\RequireJs\Config at points #1 and #2 so that getMinResolverRelativePath and getConfigFileRelativePath pass the relative path into addMinifiedSign to ensure consistency of behaviour.
Release note
No response
Triage and priority
The text was updated successfully, but these errors were encountered: