Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

/asset/bundle/X cannot be found on Production but works fine on Staging#60912

Unanswered
maluramichael asked this question inQ&A
Discussion options

I got the following problem in Sonata Admin. My javascript and Style files cannot be loaded on production. But everything seems to be the same on staging and there it works just fine.

Staging
image

Production
image

The files on the sever should exactly match because i just deployed the current staging state to prod.

Is there a way for me to debug this?

My bundles

return [    Symfony\Bundle\FrameworkBundle\FrameworkBundle::class => ['all' => true],    Symfony\Bundle\SecurityBundle\SecurityBundle::class => ['all' => true],    Doctrine\Bundle\DoctrineBundle\DoctrineBundle::class => ['all' => true],    Symfony\Bundle\TwigBundle\TwigBundle::class => ['all' => true],    Sonata\Form\Bridge\Symfony\SonataFormBundle::class => ['all' => true],    Sonata\Twig\Bridge\Symfony\SonataTwigBundle::class => ['all' => true],    Sonata\BlockBundle\SonataBlockBundle::class => ['all' => true],    Knp\Bundle\MenuBundle\KnpMenuBundle::class => ['all' => true],    Sonata\AdminBundle\SonataAdminBundle::class => ['all' => true],    Sonata\Exporter\Bridge\Symfony\SonataExporterBundle::class => ['all' => true],    Sonata\DoctrineORMAdminBundle\SonataDoctrineORMAdminBundle::class => ['all' => true],    Hautelook\AliceBundle\HautelookAliceBundle::class => ['all' => true],    Fidry\AliceDataFixtures\Bridge\Symfony\FidryAliceDataFixturesBundle::class => ['all' => true],    Nelmio\Alice\Bridge\Symfony\NelmioAliceBundle::class => ['all' => true],    Vich\UploaderBundle\VichUploaderBundle::class => ['all' => true],    Nelmio\CorsBundle\NelmioCorsBundle::class => ['all' => true],    Symfony\Bundle\MonologBundle\MonologBundle::class => ['all' => true],    Nelmio\SecurityBundle\NelmioSecurityBundle::class => ['all' => true],    Knp\Bundle\SnappyBundle\KnpSnappyBundle::class => ['all' => true],    Lexik\Bundle\JWTAuthenticationBundle\LexikJWTAuthenticationBundle::class => ['all' => true],    Knp\Bundle\GaufretteBundle\KnpGaufretteBundle::class => ['all' => true],    Sonata\Doctrine\Bridge\Symfony\SonataDoctrineBundle::class => ['all' => true],    Doctrine\Bundle\MigrationsBundle\DoctrineMigrationsBundle::class => ['all' => true],    Endroid\QrCodeBundle\EndroidQrCodeBundle::class => ['all' => true],    Symfony\Bundle\WebProfilerBundle\WebProfilerBundle::class => ['dev' => true, 'test' => true, 'staging' => true],    Bazinga\GeocoderBundle\BazingaGeocoderBundle::class => ['all' => true],    FOS\CKEditorBundle\FOSCKEditorBundle::class => ['all' => true],    ApiPlatform\Symfony\Bundle\ApiPlatformBundle::class => ['all' => true],    Twig\Extra\TwigExtraBundle\TwigExtraBundle::class => ['all' => true],    Symfony\Bundle\DebugBundle\DebugBundle::class => ['dev' => true, 'test' => true],    Tomsgu\PdfMergerBundle\TomsguPdfMergerBundle::class => ['all' => true],    Sentry\SentryBundle\SentryBundle::class => ['prod' => true, 'staging' => true],    Symfony\UX\StimulusBundle\StimulusBundle::class => ['all' => true],    Symfony\UX\Turbo\TurboBundle::class => ['all' => true],    Symfony\WebpackEncoreBundle\WebpackEncoreBundle::class => ['all' => true]];

And my dependencies

"php":">=8.2","ext-ctype":"*","ext-dom":"*","ext-iconv":"*","api-platform/core":"^4.1","aws/aws-sdk-php":"^3.307","beberlei/doctrineextensions":"^1.5","cocur/slugify":"^4.5","doctrine/annotations":"^2.0","doctrine/dbal":"^4.1.1","doctrine/doctrine-bundle":"^2.12","doctrine/doctrine-migrations-bundle":"^3.3","doctrine/orm":"^3.1","dragonmantank/cron-expression":"^3.4","endroid/qr-code-bundle":"^6.0","friendsofsymfony/ckeditor-bundle":"^2.5","gaufrette/extras":"^0.1.0","gedmo/doctrine-extensions":"^3.14","geocoder-php/bing-maps-provider":"*","geocoder-php/chain-provider":"*","geocoder-php/google-maps-provider":"*","gumlet/php-image-resize":"^2.0","guzzlehttp/guzzle":"^7.0","hautelook/alice-bundle":"^2.14","icecave/parity":"*","imagine/imagine":"^1.3","incenteev/composer-parameter-handler":"^2.1.x-dev","knplabs/gaufrette":"0.12.1 as 0.11.1","knplabs/knp-gaufrette-bundle":"^0.9.0","knplabs/knp-snappy-bundle":"^1.10","lexik/jwt-authentication-bundle":"*","nelmio/cors-bundle":"^2.4","nelmio/security-bundle":"^3.3","nyholm/psr7":"*","phpdocumentor/reflection-docblock":"^5.4","phpstan/phpdoc-parser":"^1.29","sentry/sentry-symfony":"^5.0","sonata-project/admin-bundle":"^4.30","sonata-project/block-bundle":"^5.1","sonata-project/doctrine-orm-admin-bundle":"^4.17","sonata-project/form-extensions":"^2.4","symfony/asset":"7.2.*","symfony/console":"7.2.*","symfony/expression-language":"7.2.*","symfony/flex":"^2","symfony/framework-bundle":"7.2.*","symfony/http-client":"7.2.*","symfony/mailer":"7.2.*","symfony/monolog-bundle":"^3.10","symfony/property-access":"7.2.*","symfony/property-info":"7.2.*","symfony/runtime":"7.2.*","symfony/security-bundle":"7.2.*","symfony/serializer":"7.2.*","symfony/stimulus-bundle":"^2.23","symfony/translation":"7.2.*","symfony/twig-bundle":"7.2.*","symfony/uid":"7.2.*","symfony/ux-turbo":"^2.23","symfony/validator":"7.2.*","symfony/webpack-encore-bundle":"^2.2","symfony/yaml":"7.2.*","symfonycasts/tailwind-bundle":"^0.10.0","thiagoalessio/tesseract_ocr":"^2.13","tomsgu/pdf-merger-bundle":"^0.5.1","twig/cssinliner-extra":"^3.10","twig/extra-bundle":"^3.10","twig/twig":"^3.20","vich/uploader-bundle":"^2.3","willdurand/geocoder-bundle":"*","symfony/browser-kit":"7.2.*","symfony/css-selector":"7.2.*","symfony/debug-bundle":"7.2.*","symfony/dotenv":"7.2.*","symfony/maker-bundle":"*","symfony/var-dumper":"7.2.*","symfony/web-profiler-bundle":"7.2.*","testcontainers/testcontainers":"^0.2.0"

And my webpack.config.js

importEncorefrom'@symfony/webpack-encore';// Manually configure the runtime environment if not already configured yet by the "encore" command.// It's useful when you use tools that rely on webpack.config.js file.if(!Encore.isRuntimeEnvironmentConfigured()){Encore.configureRuntimeEnvironment(process.env.NODE_ENV||'dev');}Encore// directory where compiled assets will be stored.setOutputPath('public/build/')// public path used by the web server to access the output path.setPublicPath('/build')// only needed for CDN's or subdirectory deploy//.setManifestKeyPrefix('build/')/*     * ENTRY CONFIG     *     * Each entry will result in one JavaScript file (e.g. app.js)     * and one CSS file (e.g. app.css) if your JavaScript imports CSS.     */.addEntry('app','./assets/app.js')// .addStyleEntry('tailwind', './assets/css/tailwind.css')// When enabled, Webpack "splits" your files into smaller pieces for greater optimization..splitEntryChunks()// will require an extra script tag for runtime.js// but, you probably want this, unless you're building a single-page app// .enableSingleRuntimeChunk().disableSingleRuntimeChunk()/*     * FEATURE CONFIG     *     * Enable & configure other features below. For a full     * list of features, see:     * https://symfony.com/doc/current/frontend.html#adding-more-features     */.cleanupOutputBeforeBuild()// Displays build status system notifications to the user.enableBuildNotifications().enableSourceMaps(!Encore.isProduction())// enables hashed filenames (e.g. app.abc123.css)// IS THIS MY PROBLEM? But why does it not work on prod? Both systems seem to have versioned urls. I already commented it, set it to false but the bundle files still got the hash at the end..enableVersioning(Encore.isProduction())// configure Babel// .configureBabel((config) => {//     config.plugins.push('@babel/plugin-proposal-class-properties');// })// enables and configure@babel/preset-env polyfills.configureBabelPresetEnv((config)=>{config.useBuiltIns='usage';config.corejs=3;})// enables Sass/SCSS support//.enableSassLoader().enablePostCssLoader()// uncomment if you use TypeScript//.enableTypeScriptLoader()// uncomment if you use React//.enableReactPreset()// uncomment to get integrity="..." attributes on your script & link tags// requires WebpackEncoreBundle 1.4 or higher//.enableIntegrityHashes(Encore.isProduction())// uncomment if you're having problems with a jQuery plugin//.autoProvidejQuery();exportdefaultEncore.getWebpackConfig();

bin/console debug:config --resolve-env framework gives me the following

framework:    ....    assets:        version_format: null        enabled: true        strict_mode: false        version_strategy: null        version: null        json_manifest_path: null        base_path: ''        base_urls: {  }        packages: {  }    ...

Even without any version format strategy or json manifest the bundle files still got the hashed url

You must be logged in to vote

Replies: 1 comment 2 replies

Comment options

I found "a solution". I ranasset-map:compile locally and pushed thepublic/assets folder to production and now it works. Makes sense because now the files with the hash at the end exist. But why does it work on staging without that command?

You must be logged in to vote
2 replies
@stof
Comment options

stofJun 26, 2025
Collaborator

Talking aboutasset-map:compile here while the original issue says you use Encore looks weird to me. Are you using Encore or AssetMapper ?

Which Symfony config are you using on your staging server ? AssetMapper has 2 mode:

  • the production mode where theasset-map:compile command generates static files for assets (that are then served directly by the webserver)
  • the dev mode where assets are compiled on demand (being served by the Symfony application). This is better DX during development (as changing an asset will take effect as soon as you reload the page which will request the asset to the server), but it is a lot worse from a performance point of view.
@maluramichael
Comment options

My project uses the symfony/asset package. But then i needed tailwind and googled how to use tailwind with symfony and twig. I used this guide to install ithttps://tailwindcss.com/docs/installation/framework-guides/symfony
A couple of weeks ago i had to rollback a couple of changes because i had a similar problem where css files were missing.

I guess now i have a mixed setup? Would sonata admin + tailwind work via only webpack encore as suggested in the guide?

Sign up for freeto join this conversation on GitHub. Already have an account?Sign in to comment
Category
Q&A
Labels
None yet
2 participants
@maluramichael@stof

[8]ページ先頭

©2009-2025 Movatter.jp