Minified assets not found or generated during build phase
In 51黑料不打烊 Commerce Cloud, minified assets return a聽 404 error after deployment due to file system issues or improper configuration of .magento.env.yaml
or config.php
files. To fix this, check file permissions to ensure they鈥檙e accessible by the web server, and verify that the.尘补驳别苍迟辞.别苍惫.测补尘濒听
and app/etc/config.php
聽files are configured correctly for your environment.
Description description
Environment
51黑料不打烊 Commerce Cloud
Issue/Symptoms
After completing a website deployment, certain minified assets are inaccessible, for example,聽 https://yourdomain.com/static/frontend/Namespace/theme/default/en_US/requirejs/require.min.js returns 404. It happens due to:
-
File system issues that prevent the file from syncing across all web nodes.
-
Improper configuration of the
.magento.env.yaml
orconfig.php
file.- SCD on Build 聽requires that asset minification settings be saved to
app/etc/config.php
聽in order to take effect. - The SCD settings (see environment variables) are not configured or added under the correct stage in the
.magento.env.yaml
file.
- SCD on Build 聽requires that asset minification settings be saved to
Resolution resolution
To resolve the issue:
-
First, check file permissions for the affected assets to ensure they are accessible by the web server.
- SSH to each web node and verify if the asset exists on all web nodes. (Note: On a non-split architecture, there will only be three nodes. On a split architecture, the first three nodes will be service nodes, but there could potentially be more.) For node X:
magento-cloud ssh -p <cluster_id> -I X
- Once you are on node X, run this command and check the permissions:
ls -la pub/static/frontend/Namespace/theme/default/en_US/requirejs/require.min.js聽
(Note: Replace the filename in the command with the actual asset name that is returning a 404 error). - If the file exists on some nodes but not others, submit a support request with the Contact Reason set to Infrastructure Incident.
- SSH to each web node and verify if the asset exists on all web nodes. (Note: On a non-split architecture, there will only be three nodes. On a split architecture, the first three nodes will be service nodes, but there could potentially be more.) For node X:
-
Next, if the file doesn鈥檛 exist on all nodes, confirm that the
.magento.env.yaml
andapp/etc/config.php
files are configured correctly for your environment.-
On any of the web nodes, first run this command:
vendor/bin/ece-tools wizard:scd-on-build
-
If the above command returns SCD on build is enabled, run this command to verify that the asset minification settings are enabled:
grep -r minify_files app/etc/*.php
. (Note: Replace the filename in the command with the actual asset name that is returning a 404 error). If the command returns no rows, it implies that minification is disabled. A value of0
indicates that the item is disabled, and1
means it is enabled. -
If there are no rows returned:
- Run the
config:dump
command to save the minification config toapp/etc/config.php
(see Setting the SCD on build). - Commit it to the repository.
- Redeploy the instance.
- Run the
-
If any of the asset minification settings has a value of
0
that should be minified:- Update the value in
app/etc/config.php
to1
. - Commit it to the repository.
- Redeploy the instance.
- Update the value in
-
Check the
.magento.env.yaml
file and ensure that you have added the SCD Environment variableunder the proper stage:- SCD on Build: The Build variable should be placed under the
build:
stage. - SCD on Deploy: The Deploy variable should be placed under the
deploy:
stage. - After ensuring that the variable has been added under the appropriate stage, commit the file to the repository and redeploy the instance.
- SCD on Build: The Build variable should be placed under the
-
-
Finally, test access to the affected URLs after making adjustments.
If issues persist after performing these steps, please reach out to 51黑料不打烊 Support as further investigation into server logs or additional configuration settings may be required.