I am working on a project in Symfony 4.2 with Webpack. I'm versioning my code with BitBucket and I'm using heroku for my deployment. The app work very well on dev environnement on my local machine. But I have an error in production mode on Heroku. The server can not find the file manifest.json, and my asset files generate 404 errors.
Here is the contents of my assets.yaml config file:
framework:
assets:
json_manifest_path: '%kernel.project_dir%/public/build/manifest.json'
Below are the errors I have:
2019-01-23T14:17:36.377047+00:00 app[web.1]: [2019-01-23 14:17:36] request.INFO: Matched route "app_login". {"route":"app_login","route_parameters":{"_route":"app_login","
_controller":"App\\Controller\\SecurityController::login"},"request_uri":"http://**********.herokuapp.com/","method":"GET"} []
2019-01-23T14:17:36.377226+00:00 app[web.1]: [2019-01-23 14:17:36] security.DEBUG: Checking for guard authentication credentials. {"firewall_key":"main","authenticators":1
} []
2019-01-23T14:17:36.377448+00:00 app[web.1]: [2019-01-23 14:17:36] security.DEBUG: Checking support on guard authenticator. {"firewall_key":"main","authenticator":"App\\Se
curity\\LoginFormAuthenticator"} []
2019-01-23T14:17:36.377787+00:00 app[web.1]: [2019-01-23 14:17:36] security.DEBUG: Guard authenticator does not support the request. {"firewall_key":"main","authenticator"
:"App\\Security\\LoginFormAuthenticator"} []
2019-01-23T14:17:36.379214+00:00 app[web.1]: [2019-01-23 14:17:36] security.INFO: Populated the TokenStorage with an anonymous Token. [] []
**2019-01-23T14:17:36.379828+00:00 app[web.1]: [2019-01-23 14:17:36] request.CRITICAL: Uncaught PHP Exception Twig_Error_Runtime: "An exception has been thrown during the re
ndering of a template ("Asset manifest file "/app/public/build/manifest.json" does not exist.")." at /tmp/build_6b468a926db1e3ce965958cbead3b64f/templates/base.html.twig l
ine 8 {"exception":"[object] (Twig_Error_Runtime(code: 0): An exception has been thrown during the rendering of a template (\"Asset manifest file \"/app/public/build/manif
est.json\" does not exist.\"). at /tmp/build_6b468a926db1e3ce965958cbead3b64f/templates/base.html.twig:8, RuntimeException(code: 0): Asset manifest file \"/app/public/buil
d/manifest.json\" does not exist. at /app/vendor/symfony/asset/VersionStrategy/JsonManifestVersionStrategy.php:57)"} []
2019-01-23T14:17:36.380146+00:00 app[web.1]: 10.92.136.3 - - [23/Jan/2019:14:17:36 +0000] "GET / HTTP/1.1" 500 918 "-" "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebK
it/537.36 (KHTML, like Gecko) Chrome/71.0.3578.98 Safari/537.36**
I also tried to disable access to the manifest.json file in the assets.yaml config file. And I get 404 errors on my asset files:
2019-01-23T15:45:20.646929+00:00 app[web.1]: 10.10.240.248 - - [23/Jan/2019:15:45:20 +0000] "GET / HTTP/1.1" 200 3878 "-" "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleW
ebKit/537.36 (KHTML, like Gecko) Chrome/71.0.3578.98 Safari/537.36
2019-01-23T15:45:20.821244+00:00 app[web.1]: 10.10.240.248 - - [23/Jan/2019:15:45:20 +0000] "GET /build/app.css HTTP/1.1" 404 211 "https://***********.herokuapp.com/" "M
ozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/71.0.3578.98 Safari/537.36
2019-01-23T15:45:20.830189+00:00 app[web.1]: 10.13.65.189 - - [23/Jan/2019:15:45:20 +0000] "GET /build/libs/jquery/tether/dist/js/tether.min.js HTTP/1.1" 404 244 "https://
caisse-fitfit.herokuapp.com/" "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/71.0.3578.98 Safari/537.36
2019-01-23T15:45:20.962711+00:00 app[web.1]: 10.10.240.248 - -
[23/Jan/2019:15:45:20 +0000] "GET /build/libs/jquery/underscore/underscore-min.js HTTP/1.1" 404 244 "https:/
/*************.herokuapp.com/" "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/71.0.3578.98 Safari/537.36
2019-01-23T15:45:20.976373+00:00 app[web.1]: 10.13.65.189 - -
[23/Jan/2019:15:45:20 +0000] "GET /build/libs/jquery/jQuery-Storage-API/jquery.storageapi.min.js HTTP/1.1" 40
4 259 "https://*********.herokuapp.com/" "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/71.0.3578.98 Safari/537.36
2019-01-23T15:45:21.001653+00:00 app[web.1]: 10.37.18.194 - - [23/Jan/2019:15:45:21 +0000] "GET /build/libs/jquery/PACE/pace.min.js HTTP/1.1" 404 232 "https://caisse-fitfi
t.herokuapp.com/" "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/71.0.3578.98 Safari/537.36
2019-01-23T15:45:21.111050+00:00 app[web.1]: 10.10.240.248 - - [23/Jan/2019:15:45:21 +0000] "GET /build/scripts/config.lazyload.js HTTP/1.1" 404 230 "https://************
.herokuapp.com/" "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/71.0.3578.98 Safari/537.36
2019-01-23T15:45:21.121765+00:00 app[web.1]: 10.13.65.189 - - [23/Jan/2019:15:45:21 +0000] "GET /build/scripts/palette.js HTTP/1.1" 404 222 "https://***********.herokuap
p.com/" "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/71.0.3578.98 Safari/537.36
2019-01-23T15:45:21.153872+00:00 app[web.1]: 10.37.18.194 - - [23/Jan/2019:15:45:21 +0000] "GET /build/scripts/ui-load.js HTTP/1.1" 404 222 "https://caisse-fitfit.herokuap
p.com/" "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/71.0.3578.98 Safari/537.36
2019-01-23T15:45:21.160011+00:00 app[web.1]: 10.10.240.248 - -
I tested several solutions found on the net, but none works. :(
Finally I resolved the issue. th problem was the gitignore file. my file was not well configured. I added these lines to the gitignore file :
###> symfony/webpack-encore-bundle ###
/node_modules/
!/public/build/
!/public/build/*
npm-debug.log
yarn-error.log
And it works now