在magento 2.4.6云项目中,在前端网站找不到styles-m.css。前端网站已损坏。但后端仪表板运行良好

问题描述 投票:0回答:1

我有一个magento2云项目。 magento 2.4.6 版本。在 app/etc/config.php 中禁用合并和迷你 css。推送到暂存并重新部署成功后,找不到 styles-m.css styles-m.css not found

.magento.app.yaml

# This file describes an application. You can have multiple applications
# in the same project.


# The name of this app. Must be unique within a project.
name: mymagento

# The toolstack used to build the application.
type: php:8.2
build:
    flavor: none
dependencies:
    php:
        composer/composer: '2.2.21'

# Enable extensions required by Magento 2
runtime:
    extensions:
        - redis
        - xsl
        - blackfire
        - newrelic
        - sodium

# The relationships of the application with services or other applications.
# The left-hand side is the name of the relationship as it will be exposed
# to the application in the environment variable. The right-hand
# side is in the form `<service name>:<endpoint name>`.
relationships:
    database: "mysql:mysql"
    redis: "redis:redis"
    opensearch: "opensearch:opensearch"

# The configuration of app when it is exposed to the web.
web:
    locations:
        "/": &root
            # The public directory of the app, relative to its root.
            root: "pub"
            # The front-controller script to send non-static requests to.
            passthru: "/index.php"
            index:
                - index.php
            expires: -1
            scripts: true
            allow: false
            rules:
                \.(css|js|map|hbs|gif|jpe?g|png|tiff|wbmp|ico|jng|bmp|svgz|midi?|mp?ga|mp2|mp3|m4a|ra|weba|3gpp?|mp4|mpe?g|mpe|ogv|mov|webm|flv|mng|asx|asf|wmv|avi|ogx|swf|jar|ttf|eot|woff|otf|html?)$:
                    allow: true
                ^/sitemap(.*)\.xml$:
                    passthru: "/media/sitemap$1.xml"
        "/media":
            root: "pub/media"
            allow: true
            scripts: false
            expires: 1y
            passthru: "/get.php"
        "/static": &static
            root: "pub/static"
            allow: true
            scripts: false
            expires: 1y
            passthru: "/front-static.php"
            rules:
                ^/static/version\d+/(?<resource>.*)$:
                    passthru: "/static/$resource"


# The size of the persistent disk of the application (in MB).
disk: 2048

# The mounts that will be performed when the package is deployed.
mounts:
    "var": "shared:files/var"
    "app/etc": "shared:files/etc"
    "pub/media": "shared:files/media"
    "pub/static": "shared:files/static"

hooks:
    # We run build hooks before your application has been packaged.
    build: |
        set -e
        composer --no-ansi --no-interaction install --no-progress --prefer-dist --optimize-autoloader
        php ./vendor/bin/ece-tools build:generate
        php ./vendor/bin/ece-tools build:transfer
    # We run deploy hook after your application has been deployed and started.
    deploy: |
        php ./vendor/bin/ece-tools deploy
    # We run post deploy hook to clean and warm the cache. Available with ECE-Tools 2002.0.10.
    post_deploy: |
        php ./vendor/bin/ece-tools post-deploy

# Default Magento 2 cron jobs
crons:
    cronrun:
        spec: "* * * * *"
        cmd: "php bin/magento cron:run"

# Environment variables
variables:
    env:
        CONFIG__DEFAULT__PAYPAL_ONBOARDING__MIDDLEMAN_DOMAIN: 'payment-broker.magento.com'
        CONFIG__STORES__DEFAULT__PAYPAL__NOTATION_CODE: 'Magento_Enterprise_Cloud'

.magento.env.yaml

stage:
  global:
    SKIP_HTML_MINIFICATION: true
  build:
      SKIP_SCD: false
      SCD_STRATEGY: "compact"
  deploy:
    CLEAN_STATIC_FILES: trueƒst
    CRON_CONSUMERS_RUNNER:
      cron_run: true
      max_messages: 1000
      consumers:
        - product_action_attribute.update
        - exportProcessor
        - async.operations.all

生成静态文件需要40分钟 generate slow

我可以使用 git commit --allow-empty -m "redeploy" 重新部署,但每次都找不到 css。

预计: 成功生成styles-m.css

magento2
1个回答
0
投票

对于 Adobe Commerce Cloud, 以下是解决该问题的步骤。

  1. 在本地设置云项目(如果可能的话使用docker)
  2. 从项目根目录运行 php setup:static-content:deploy。
  3. 检查样式是否正在生成。
  4. 如果您在本地发现相同的错误,那么您可以访问本地的 url,一般来说,如果 less 有任何问题,您将能够在 css 本身的浏览器链接上看到错误。
  5. 如果没有任何错误,请检查主题是如何编写的。有时它可能是由于错误的主题结构或布局而发生的。

快速部署

  1. 部署后,您可以尝试更改 .magento.env.yaml 上的以下内容

stage:
   build:
       SCD_STRATEGY: "quick"

  1. 如果您只有特定主题,那么您也可以添加 SCD_MATRIX

stage:    
   build:
      SCD_MATRIX:
            "Magento/backend":
                language:
                    - en_US
                    - en_GB
            "yourthemevendor/themename":
                language:
                    - en_AU
                    - en_CA
                    - en_GB
                    - en_NZ
                    - en_US
                    - sv_SE
                    - de_DE

根据您使用的商店更改语言,这将节省非常具体的部署时间。

© www.soinside.com 2019 - 2024. All rights reserved.