问题
I'm trying to deploy to production (on a local machine) a Rails 5.2 app which uses webpacker for assets managemnet (I have totally replaced the assets pipeline).
Everything seems ok: as part of my deployment process I run the webpacker:compile
task and both JS and CSS are compiled in the public/packs
folder.
However, the assets aren't loaded from the app even if they are correctly linked.
Am I missing anything here?
I have tried to load via browser other files in the /public
folder (i.e. robots.txt
) but they are not availble neither. I get "The page you were looking for doesn't exist." error message.
回答1:
In production by default rails expects to be behind a reverse proxy server like nginx that will serve all static files from public
more efficiently.
Also for low loads the built-in file server can be enabled as a quick-fix, in production.rb
:
config.public_file_server.enabled = true
来源:https://stackoverflow.com/questions/55182801/loading-webpacker-assets-in-production