Loading webpacker assets in production

时间秒杀一切 提交于 2021-01-28 13:52:04

问题


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

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!